Concrete Proposal: while ... and while ...
Barry A. Warsaw
bwarsaw at cnri.reston.va.us
Fri May 21 09:58:40 EDT 1999
>>>>> "PP" == Paul Prescod <paul at prescod.net> writes:
PP> Python keywords can't be used as variable names. Today, "do"
PP> could be a variable name in some obscure piece of
PP> code. Personally I think that the tiny bit of breakage would
PP> be worth it but strictly speaking it would be a (mildly)
PP> backwards-incompatible change.
PP> do=15
PP> If we loosened the rule against using keywords, or made an
PP> exception for "do" then it could be implemented in a
PP> backwards-compatible manner by looking for the colon. I find I
PP> often want to use class as a variable name...
JPython has loosened the rules somewhat:
JPython 1.1beta1 on java1.2.1
Copyright © 1997-1999 Corporation for National Research Initiatives
>>> class C: pass
...
>>> C.for = 7
but this wouldn't help if the keyword were used as a non-attribute:
>>> for = 7
Traceback (innermost last):
(no code object) at line 0
File "<console>", line 1
for = 7
^
SyntaxError: invalid syntax
So if CPython adopted the same loosening, it might alleviate the
problem in many, but not all, circumstances.
-Barry
More information about the Python-list
mailing list