unicode as valid naming symbols

Chris Angelico rosuav at gmail.com
Tue Apr 1 09:08:14 EDT 2014


On Tue, Apr 1, 2014 at 11:29 PM, Roy Smith <roy at panix.com> wrote:
>> But I confess that is mostly personal taste, since I find names_like_this
>> ugly. Names-like-this look better to me but that wouldn't be workable
>> in python. But maybe there is some connector that would be aestetically
>> pleasing and not causing other problems.
>
> Semi-seriously, let me suggest (names like this).  It's not valid syntax
> now, so it can't break any existing code.  It reuses existing
> punctuation in a way which is a logical extension of its traditional
> meaning, i.e. "group these things together".

I'd really rather not have a drastically different concept of "name"
to every other language's definition! Reading over COBOL code is
confusing in ways that reading, say, Ruby code isn't; the ? and !
suffixes aren't nearly as confusing as:

http://www.math-cs.gordon.edu/courses/cs323/COBOL/cobol.html
"""
COBOL identifers are 1-30 alphanumeric characters, at least one of
which must be non-numeric.
In certain contexts it is permissible to use a totally numeric
identifier; however, that usage
is discouraged.  Hyphens may be included in an identifier anywhere
except the first of last
character.
"""

Hyphens in names! Ugh! That means subtraction! :)

But there is a solution! You can have *anything you want* in your
identifiers. Watch:

v = {}

v["names like this"] = 42
print(v["names like this"])

Yes, that's a five-character delimiter/marker. But it works!!

ChrisA



More information about the Python-list mailing list