[Python-Dev] ACCEPTED: PEP 285

Neal Norwitz neal at metaslash.com
Wed Apr 3 18:13:29 EST 2002


Guido van Rossum wrote:
> 
> Despite the negative feedback, I've decided to accept the PEP.  The
> most important perceived problem is that newbies tend to write
> 
>     if x == True: ...
> 
> where they should write
> 
>     if x: ...
> 
> I believe this problem should be solved by education (the Zen master
> hits the student on the head with a stick, and the student gets
> enlightenment) rather than by holding back what I believe will be a
> useful feature.  You can expect the bool type in Python 2.3; it will
> be in CVS tonight.

And the warnings have already been added to pychecker.
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

	def test(a):
	    if a is True: print 'True'
	    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

Neal





More information about the Python-list mailing list