Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.139.MISMATCH!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; '*not*': 0.07; 'plenty': 0.07; 'ascii': 0.09; 'contexts': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '2.7': 0.14; '__future__': 0.16; 'different,': 0.16; 'directive': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'identifiers,': 0.16; 'identifiers;': 0.16; 'keyword,': 0.16; 'keywords)': 0.16; 'lexer': 0.16; 'non-ascii': 0.16; 'optional.': 0.16; 'targets': 0.16; 'think.': 0.16; 'applies': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; '(but': 0.19; 'subject:need': 0.19; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'instance,': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'on,': 0.29; 'characters': 0.30; 'message- id:@mail.gmail.com': 0.30; 'context,': 0.31; 'helpful.': 0.31; 'quite': 0.32; 'worked': 0.33; 'cases': 0.33; 'fri,': 0.33; 'agree': 0.35; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'half': 0.37; 'wrong': 0.37; 'pm,': 0.38; 'rather': 0.38; 'extremely': 0.39; 'sure': 0.39; 'even': 0.60; 'truly': 0.60; 'simple': 0.61; 'name': 0.63; 'jul': 0.74; '3.4': 0.84; 'colored': 0.84; 'partially': 0.84; 'technically': 0.84; 'absolutely': 0.87; 'to:none': 0.92; 'constitute': 0.93; 'rick': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=bG21hwr5cxykNMZ56WHY9GlnL/NLj4LtfbohaiueLh4=; b=S02vqhQrbCUDl7WIqQSMhONqLaqFOHPjCsCNvZur08fTGJXnAcBEri/ujNgzGauwfV fRdG39z94yPZUXzLfRt4cz10SU7qYs4hWfj4HEsqG9Uf5ByFEGvAP/2N1qoDxFYFMYsM smPGL1yh6EKbw8fXbIzeVO9bHSCYS/80yFypIomcFjH51T/jJ4z0uTJ/Hn50O261UEDg JxKhxhiBcwGCu0t2y+bX2l9jnddIchPBYblspzwqztzw0BdvU2InJ2At+p/ocTDuhIOG D8mWYsaHRANg2GP3m/D5DabaK/c/VwzsThHQghoDmKDnuSpyFag/IQ8RjxXYBba17vY9 oWJQ== MIME-Version: 1.0 X-Received: by 10.220.203.134 with SMTP id fi6mr1701027vcb.18.1405653830738; Thu, 17 Jul 2014 20:23:50 -0700 (PDT) In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Date: Fri, 18 Jul 2014 13:23:50 +1000 Subject: Re: I need an idea for practise! From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405653833 news.xs4all.nl 2865 [2001:888:2000:d::a6]:44563 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74719 On Fri, Jul 18, 2014 at 1:07 PM, Rick Johnson wrote: > For me, only the following targets need colorizing: > > Keywords > Built-ins And be sure *not* to colorize built-ins (but *do* colorize keywords) in contexts where the tokens are actually identifiers, like "x.open = 1". Plus, if you want this to be truly general, you need to have it understand that some keywords aren't keywords if the shebang is different, although with 2.7 vs 3.4 that only really applies to nonlocal (if True/False/None are colored as keywords even though they're technically builtins, that's not a big deal); if you want to support Python 2.5, you'd also have to cope with a __future__ directive adding a keyword, but that's quite optional. It's not as simple as you might think. I've worked with plenty of syntax highlighters that get something wrong in some context, and it's extremely annoying; in some cases it makes the colorization actually harmful, rather than helpful. And it's absolutely *essential* that the lexer and the language agree on, for instance, what characters constitute identifiers; if I have a partially non-ASCII variable name and only the ASCII half of it gets highlighted, that can be highly distracting. ChrisA