[issue8376] Tutorial offers dangerous advice about iterators: “__iter__() can just return self”
Antoine Pitrou
report at bugs.python.org
Thu Jul 22 19:33:35 CEST 2010
Antoine Pitrou <pitrou at free.fr> added the comment:
At least equally useful would be the mention that __iter__ can be a generator, eliminating the need for intermediate objects:
>>> class C:
... def __iter__(self):
... yield 1
... yield 2
...
>>> list(C())
[1, 2]
----------
nosy: +pitrou
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8376>
_______________________________________
More information about the Python-bugs-list
mailing list