This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ysj.ray
Recipients andersk, eric.araujo, georg.brandl, ysj.ray
Date 2010-04-12.15:09:26
SpamBayes Score 7.926565e-06
Marked as misclassified No
Message-id <1271084968.84.0.176807120772.issue8376@psf.upfronthosting.co.za>
In-reply-to
Content
I think there is not much ploblem. Please notice this sentence in the previous paragraph in the toturial :

"Behind the scenes, the for statement calls iter() on the container object. The function returns an iterator object that defines the method next() which accesses elements in the container one at a time."

I think it's clear enough that the container object is different from the iterator object, what exactly has the iterator behavior is the iterator object, not the container object. And this sentence you mentioned:

"If the class defines next(), then __iter__() can just return self:"

is to teach you define a iterator, not a container. So by reading it carefully, you won't define something that is both a container and a iterator, will you? 

If you really define a next() on a class which you want it be a container, and then define a __iter__() on it and return self, then your container is exactly a generator, not a container. And a generator can certainly iterate only once.
History
Date User Action Args
2010-04-12 15:09:28ysj.raysetrecipients: + ysj.ray, georg.brandl, eric.araujo, andersk
2010-04-12 15:09:28ysj.raysetmessageid: <1271084968.84.0.176807120772.issue8376@psf.upfronthosting.co.za>
2010-04-12 15:09:27ysj.raylinkissue8376 messages
2010-04-12 15:09:26ysj.raycreate