dict.has_key(x) versus 'x in dict'

Fredrik Lundh fredrik at pythonware.com
Wed Dec 6 08:57:35 EST 2006


Bjoern Schliessmann wrote:

> Wouldn't be "if k in d.keys()" be the exact replacement?

no.  that would convert an O(1) operation to an O(n) operation, which 
would be rather silly.

</F>




More information about the Python-list mailing list