list index()

Carsten Haese carsten at uniqsys.com
Sat Sep 1 04:13:16 CEST 2007


On Sat, 2007-09-01 at 13:50 +1200, Lawrence D'Oliveiro wrote:
> In message <mailman.156.1188498891.28954.python-list at python.org>, Carsten
> Haese wrote:
> > has_key() will go away, period. It has been made obsolete by "in", which
> > is faster and more concise.
> 
> And is also a backdoor way of introducing non-virtual methods into Python,
> is it not.

If by that you mean that "in" tests can't be overridden, that's not
true:

>>> class LyingDict(dict):
...   def __contains__(self, key): return False
... 
>>> d = LyingDict()
>>> d[1] = 42
>>> 1 in d
False

If you mean something else, please clarify.

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list