Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74719

Re: I need an idea for practise!

References (1 earlier) <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> <mailman.11933.1405617616.18130.python-list@python.org> <b38e352c-e125-46ca-af04-3e0de345009a@googlegroups.com> <mailman.11974.1405649023.18130.python-list@python.org> <a6a835d3-e39a-4a06-b6e9-e8370152a4fd@googlegroups.com>
Date 2014-07-18 13:23 +1000
Subject Re: I need an idea for practise!
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.11979.1405653833.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jul 18, 2014 at 1:07 PM, Rick Johnson
<rantingrickjohnson@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

I need an idea for practise! Nicholas Cannon <nicholascannon1@gmail.com> - 2014-07-17 02:59 -0700
  Re: I need an idea for practise! alister <alister.nospam.ware@ntlworld.com> - 2014-07-17 10:13 +0000
  Re: I need an idea for practise! Abhiram R <abhi.darkness@gmail.com> - 2014-07-17 19:03 +0530
  Re: I need an idea for practise! Chris Angelico <rosuav@gmail.com> - 2014-07-18 00:20 +1000
  Re: I need an idea for practise! Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-17 09:34 -0700
    Re: I need an idea for practise! Chris Angelico <rosuav@gmail.com> - 2014-07-18 03:20 +1000
      Re: I need an idea for practise! Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-17 12:30 -0700
        Re: I need an idea for practise! Paul McNett <paul@mcnettware.com> - 2014-07-17 13:21 -0700
        Re: I need an idea for practise! Chris Angelico <rosuav@gmail.com> - 2014-07-18 12:03 +1000
          Re: I need an idea for practise! Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-17 20:07 -0700
            Re: I need an idea for practise! Chris Angelico <rosuav@gmail.com> - 2014-07-18 13:23 +1000
              Re: I need an idea for practise! Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-17 21:06 -0700
                Re: I need an idea for practise! Chris Angelico <rosuav@gmail.com> - 2014-07-18 16:00 +1000
    Re: I need an idea for practise! Terry Reedy <tjreedy@udel.edu> - 2014-07-17 17:46 -0400
    Re: I need an idea for practise! Chris Angelico <rosuav@gmail.com> - 2014-07-18 12:04 +1000
  Re: I need an idea for practise! Orochi <kartikjagdale11@gmail.com> - 2014-07-17 11:05 -0700
    Re: I need an idea for practise! AudreyJean <iamAudreyJean@gmail.com> - 2014-07-18 08:42 -0700
  Re: I need an idea for practise! Nicholas Cannon <nicholascannon1@gmail.com> - 2014-07-17 19:03 -0700

csiph-web