Names changed to protect the guilty

John J. Lee jjl at pobox.com
Sat Oct 7 20:41:36 EDT 2006


aahz at pythoncraft.com (Aahz) writes:

> The following line of lightly munged code was found in a publicly
> available Python library...
> 
>     if schema.elements.has_key(key) is False:
> 
> Sorry, just had to vent.

I think I was reading the same code recently (epydoc?) and was also
momentarily horrified ;-) until I realized that it was quite
deliberately using three-valued logic (True, False, None) for some
presumably-sensible reason.  Since None is false, they had to use
"is".  So, given the need for three-valued logic, it's not as silly as
it looks.


John



More information about the Python-list mailing list