I need an idea for practise!

Chris Angelico rosuav at gmail.com
Fri Jul 18 08:00:16 CEST 2014

On Fri, Jul 18, 2014 at 2:06 PM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> On Thursday, July 17, 2014 10:23:50 PM UTC-5, Chris Angelico wrote:
>> And be sure *not* to colorize built-ins (but *do* colorize
>> keywords) in contexts where the tokens are actually
>> identifiers, like "x.open = 1".
> Just check for word boundaries on all your keywords and
> built-ins and you're *DONE*!

Of course, because (True.real) is just as much not-a-keyword as
(real.True), naturally.

>> 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.
> Stop it, you're embarrassing yourself with all this rambling!
> You should have shut up a long time ago. Just like the
> thread where you embarrassed yourself with your limited
> knowledge of IDLE[1] and Tkinter, you're now really loosing
> all respect as a competent programmer if you cannot even
> write these "simple" regexps.

Simple regexps that differ in one tiny part based on something way
earlier? Sure, they're simple in the sense that you can devolve them
into very simple components. By the same token, all Python programs
are simple, because there are only 101 opcodes. Doesn't make it

>> 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.
> Oh i get it now, your confusing Python with REXX again...
>     *face palm*

I am? Oh right, because REXX totally has non-ASCII variable names, and
because I was always using syntax highlighting back in the 90s, but I
don't do it now. Of course.


More information about the Python-list mailing list