[Python-Dev] Constancy of None
Michael Hudson
mwh at python.net
Mon Jul 19 17:32:39 CEST 2004
"Raymond Hettinger" <python at rcn.com> writes:
> [Raymond]
>> > That raises the question. Since there was a SyntaxWarning in Py2.3,
>> > should it have been escalated to an error for Py2.4?
>
> [AMK]
>> > +1.
>> >
>> > (And is it time to make assignments to True and False trigger a
>> > SyntaxWarning, or should that wait until 2.5?)
>
> [Guido]
>> We should be much more conservative with that. There's tons of code
>> out there that assigns these (conditionally, if it's 2.3-aware) to
>> truth values and we don't want to break that.
>
> We may never (prior to Py3.0) be able to block assignments to
> True/False; however, some lesser restriction could be feasible. For
> example, it may be possible to require that the assignment have the same
> boolean value so that "True=x" rejects when bool(x)!=True. The would
> allow "True=1" and
> "True=(1==1)" statements to work while still enabling the compiler to
> optimize the test out of "while True".
Sounds, um, challenging to implement. I guess you could emit
different code for an assignment to True than for other identifiers...
> While I'm not sure this is a great idea, I would have no remorse for
> wrecking a piece of code that assigned "True=0" ;-)
But what about "True=1" or even "True=[1]"?
Cheers,
mwh
--
If I didn't have my part-time performance art income to help pay
the bills, I could never afford to support my programming
lifestyle. -- Jeff Bauer, 21 Apr 2000
More information about the Python-Dev
mailing list