[Python-Dev] Code Generation Idea Was: Bytecode idea
Skip Montanaro
skip@pobox.com
Wed, 26 Feb 2003 09:14:14 -0600
>> None is moving slowly toward becoming a true constant. Perhaps the
>> same should be true of True and False.
Guido> Problem with this is that there's currently lots of code out
Guido> there that was recently modified to read
Guido> try:
Guido> True
Guido> except NameError:
Guido> True = 1
Guido> False = 0
Guido> That would become a syntax error if True/False were true
Guido> constants. :-(
Hmmm... Those code blocks would only be executed on older versions of the
interpreter. Is there some way to use that knowledge to finesse the
problem? It would be a real hack, but if the compiler recognized precisely
the above construct (or at least assignment in an except block guarded by
NameError), it could shut up about the assignment.
Skip