ACCEPTED: PEP 285
Andrew Dalke
dalke at dalkescientific.com
Thu Apr 4 03:24:31 EST 2002
Guido:
>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)
Personally, my problems with the PEP were mere quibbles, so I didn't
comment. I think most code that breaks with this change wasn't very
good code in the first place. But I've reading through Boudewijn
Rempt's QT book at
http://www.opendocspublishing.com/pyqt/index.lxp?lxpwrap=c1267%2ehtm
and noticed
def add(self, occasion, function):
if self.connections.has_key(occasion) == 0:
self.connections[occasion]=[function]
else:
self.connections[occasion].append(function)
when it should have said
if not self.connection.has_key(occasion):
I know this will still work correctly since False == 0,
but I suspect this means there's many people who are doing
explicit checks for 0/1 (/whatever?) for truth tests.
Treat this post as a stick. :)
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list