value of: None is None is None

Thomas Jollans thomas at jollans.com
Sat Jun 26 05:02:55 EDT 2010


On 06/25/2010 10:41 PM, Alan G Isaac wrote:
> Surprising for a moment, if you don't
> immediatelyrecognize it as a chained comparison.
> (Just sharing.)
> Alan Isaac
> 
>>>> None is None is None
> True
>>>> (None is None) is None
> False
>>>> None is (None is None)
> False
> 

Chained comparisons - one of those language features that some of the
time makes code enormously more readable, but the rest of the time are
rather disconcerting to those of us coming from pretty much any other
programming language.

Thomas



More information about the Python-list mailing list