question of style

Lie Ryan lie.1296 at gmail.com
Fri Jul 3 02:37:32 EDT 2009


Lie Ryan wrote:
> Tim Harig wrote:
>>> Speaking only to the style issue, when I've wanted to do something like
>>> that, I find:
>>>        if self.higher is None is self.lower:
>>> more readable, by making clear they are both being compared to a
>>> constant, rather than compared to each other.
>> By comparing them to *any* constant with 'is' you end up with the same
>> potential problems as to whether something with a value of None is actually
>> None?  
> 
> Oh really? None is a Singleton and all None always point to the same
> None object. And the fact that it is impossible to override `is`
> operator is the reason for the "is None" idiom.
> 

http://docs.python.org/c-api/none.html



More information about the Python-list mailing list