[issue11248] Tails of generator get lost under zip()

Greg Kochanski report at bugs.python.org
Sun Feb 20 02:41:44 CET 2011


Greg Kochanski <gpk at kochanski.org> added the comment:

The code (bug312.py) was not submitted as a "pattern", but rather as an example of a trap into which it is easy to fall, at least for the 99% of programmers who are users of the language rather than its implementers.  


The basic difference is that while one can write a function that is guaranteed to execute to the end of its body[*]; one cannot do that with a generator function.   This point ought to be made in the documentation.
[* Neglecting SIGKILL and perhaps a few abnormal cases.]

The current documentation emphasizes the analogy to functions (which can be misleading) and (in section 6.8) explictly says that the normal behaviour of a generator function is to run all the way to completion.

----------

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


More information about the Python-bugs-list mailing list