Iteratoration question

andrew cooke andrew at
Fri Apr 3 03:38:52 CEST 2009

Rhodri James wrote:
> On Fri, 03 Apr 2009 02:07:38 +0100, grocery_stocker <cdalten at>
> wrote:
>> Would 'a' somehow call __iter__ and next()? If so, does python just
>> perform this magically?
> No.  It's "for" that invokes the iteration protocol; that's pretty
> much the definition of it.  You have read the iteration protocol
> after it's been mentioned so many times now, haven't you?

argh.  when i said "yes" i meant that something calls them - that they
realy do exist behind the scenes.  but rhodri is right (again), it's "for"
that does the work.  sorry.  andrew

More information about the Python-list mailing list