[Python-Dev] ACCEPTED: PEP 285

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Fri Apr 5 22:53:19 EST 2002


In article <mailman.1017895453.22508.python-list at python.org>, Gustavo
Niemeyer wrote:
>
>Hi Neal!
>
>> 	    if a is True: print 'True'
>[...]
>> 	test.py:6: Comparisions with True are not necessary
>
>Testing if "a is True" is ok. True and False are singletons this is
>the best way to know if 'a' is really 'True' (and not 1, [0], "foo",
>etc). This test will be necessary sometimes.

It is neither worse nor better than using '==', IMO. Yes, it is a
singleton, but the danger is using 'a is True' instead of simply 'a'.

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list