"is" and "=="
tjreedy at udel.edu
Tue Mar 11 21:39:54 CET 2003
"John Hunter" <jdhunter at ace.bsd.uchicago.edu> wrote in message
news:mailman.1047404720.9129.python-list at python.org...
> >>>>> "Thomas" == Thomas Wouters <thomas at xs4all.net> writes:
> Thomas> There are very few uses of 'is' in normal user code...
> Thomas> (much like 'from module import *' :)
> What about
> if x is None: do_something()
> I use that all the time.
That is one of the few uses, and is recommended over 'x == None'. 'x
is True' would be except that 'x' and 'x is True' have the same
logical value and thus the extra test is useless. Similarly for 'not
x' and 'x is False' (the former might also be faster).
More information about the Python-list