On 5/14/2018 6:58 PM, Greg Ewing wrote:
Terry Reedy wrote:
the first two 'and's in "a and b.and # and error" are tagged. To not
tag the second would require full parsing,
That particular case could be handled by just not colouring
any word following a dot.
OK, more parsing, even if not complete. Other cases require looking at
several other things before or after, depending on the exact proposal.
Okay, more parsing, depending on the exact rules. Some of the variations (
Some other situations might result in false positives, but
there are cases like that already. Many Python colourisers
colour any occurrence of a builtin function name, even if
it has been shadowed, and people seem to live with that.
For IDLE:
>>> def int(): return 0 # int colored as defined name
>>> int() # int colored as builtin.
0
Perhaps I should add a check whether defined names are builtins, and if
so, color them as builtins even after 'def' and 'class'.
It might even be useful, if it alerts people that a name
they're using is reserved in some contexts, and so might
be best avoided.
Since IDLE is especially aimed at beginners, I could think the same
about shadowing keywords, and leave them always marked as such.
Terry Jan Reedy
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/