Denis S. Otkidach wrote:
I believe it's a bad idea to remove this method, since behavior of both
"item in dict" and "for item in dict" (especially the later) in Python
does't seem sane to me.  Just look at reverse operations:

dict.fromkeys(seq) <-> d.keys(), d.iterkeys() - OK
dict(iterable) <-> d.iteritems()              - why not iter(d)?
dict(l) <-> d.items()                         - why not list(d)?
dict(seq) <-> d.keys(), d.iterkeys()          - looks very strange.

And those ("item in dict" and "for item in dict") are related of course,
since the following should pass:

for item in d:
    assert item in d

That's the reason why I always prefer to use has_key() and iteritems()
to in and iter().

Huh? I'm not following your logic. Why is "item in dict" less readable than "dict.has_key(item)"? Something to do with expecting inverses that don't exist?


Personally, I use "item in dict" because it's quite readable to me, and generally faster.

STeVe
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to