[issue8376] Tutorial offers dangerous advice about iterators: “__iter__() can just return self”

Amaury Forgeot d'Arc report at bugs.python.org
Thu Jul 22 19:40:54 CEST 2010


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

Why do you call this "dangerous"? because the object can be iterated only once? But reversed() does the same thing.
And all iterators objects must also implement the __iter__ method that return themselves, otherwise they cannot be used in a for loop.
Better start with such an object.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8376>
_______________________________________


More information about the Python-bugs-list mailing list