PEP 3131: Supporting Non-ASCII Identifiers

Duncan Booth duncan.booth at invalid.invalid
Thu May 17 03:50:53 EDT 2007


"Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> wrote:

> - Someone proposed using escape sequences of some kind, supported by  
> editor plugins, so there is no need to modify the parser.

I'm not sure whether my suggestion below is the same as or a variation
on this. 

> 
> - Refactoring tools should let you rename foreign identifiers into
> ASCII  only.

A possible modification to the PEP would be to permit identifiers to
also include \uxxxx and \Uxxxxxxxx escape sequences (as some other
languages already do). Then you could have a script easily (and
reversibly) convert all identifiers to ascii or indeed any other
encoding or subset of unicode using escapes only for the unrepresentable
characters. 

I think this would remove several of the objections: such as being
unable to tell at a glance whether someone is trying to spoof your
variable names, or being unable to do minor maintenance on code using
character sets which your editor doesn't support: you just run the
script which would be included with every copy of Python to restrict the
character set of the source files to whatever character set you feel
happy with. The script should also be able to convert unrepresentable
characters in strings and comments (although that last operation
wouldn't be guaranteed reversible). 

Of course it doesn't do anything for the objection about such
identifiers being ugly, but you can't have everything.



More information about the Python-list mailing list