<var> is None vs. <var> == None
Terry Reedy
tjreedy at udel.edu
Mon Jan 26 15:29:29 EST 2009
Steve Holden wrote:
> Terry Reedy wrote:
>> In 2.x, the *names* 'True' and 'False' can be rebound because bool is
>> new and people write
>> try:
>> False,True
>> except NameError:
>> False,True = 0,1
>>
>> to make code back compatible.
>>
> I would claim that the ability to rebind True and False is a simple bug,
> though one not likely to be fixed in an 2.x release. The code above
> doesn't rebind True and False in interpreters that have them ...
In pre-bool 2.x, people never wrote the above but sometime wrote
False,True = 0,1
To me it is hardly a bug to not gratuitously break substantial amounts
of proper code.
>> Back before rebinding 'None' was prohibited, 'is None' was not
>> completely guaranteed either (absent reading the rest of a file to be
>> sure no rebinding would be done).
>>
> And that was a bug too, in this case one that *was* removed in 2.4, I
> believe. Don't have 2.3 lying around just now.
Unlike with True and False, the devs could not think of or find any
proper use case for rebinding None and judged that the new prohibition
would break very little if any code. As far as I know, they were correct.
tjr
More information about the Python-list
mailing list