Names changed to protect the guilty
JohnRoth1 at jhrothjr.com
Sat Oct 7 15:05:05 CEST 2006
> 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.
> Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Uh, guys. IMO, the clearest way of writing this is:
if key not in schema.elements:
Unless, of course, your code has to run in a
Python release earlier than 2.2. But then you
wouldn't be testing for the False object anyway.
More information about the Python-list