On 5 February 2013 03:56, eryksun <eryk...@gmail.com> wrote:
> On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel <da...@davea.name> wrote:
>>> Nope, in both Python 2 and 3 iterating over a dict directly just
>>> provides the key. That's also how "if key in dict" works.
>
> A dict implements __contains__ for an efficient "in" test. In general,
> the interpreter falls back to using iteration if a type lacks
> __contains__.

I almost wrote this response but then I realised that Dave probably
meant that "obj in dict" returns True if the dict has a key equal to
obj rather than if the dict has a (key, value) pair equal to obj.


Oscar
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to