[Python-Dev] ACCEPTED: PEP 285

Gustavo Niemeyer niemeyer at conectiva.com
Wed Apr 3 23:42:55 EST 2002


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.

> 	    if a == False: print 'False'
[...]
> 	test.py:7: Comparisions with False are not necessary

This should probably say something more agressive, like
"Comparisions with boolean values may be dangerous", since this
may give undesirable results (if the user was trying to check
for False, and not for 0, [], "", etc).

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]





More information about the Python-list mailing list