[Python-Dev] ACCEPTED: PEP 285

Guido van Rossum guido@python.org
Wed, 03 Apr 2002 19:52:15 -0500

> And the warnings have already been added to pychecker.

I knew I could count on you. :-)

> I know I'm going to wish I never said this, but ...
> If you find REAL problems with code that breaks, let me know.
> I will try to address problems that may arise.
> This code:
> 	True = 1
> 	False = 0

I wonder if you should add warnings for *any* spelling, or at least
also for true and TRUE, if assigned the constant 1 (and similar for
false/FALSE), on the basis that these are probably other ways to spell
the same thing.  E.g. I've seen

        FALSE, TRUE = range(2)

> 	def test(a):
> 	    if a is True: print 'True'

But 'is True' can be a useful test.  The newbies we're trying to catch
in verboten activities are using ==.

> 	    if a == False: print 'False'
> generates these warnings:
> 	test.py:2: Should not assign to True, it is (or will be) a builtin
> 	test.py:3: Should not assign to False, it is (or will be) a builtin
> 	test.py:6: Comparisions with True are not necessary
> 	test.py:7: Comparisions with False are not necessary


--Guido van Rossum (home page: http://www.python.org/~guido/)