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

Greg Kochanski report at bugs.python.org
Sat Feb 19 18:51:30 CET 2011


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

Yes, the current behaviour makes sense from a language designer's viewpoint, and maybe even from the user's viewpoint (if the user thinks about it a carefully).

But, that's not the point of a computer language.   The whole reason we program in languages like python instead of asm is to match the behaviour of the silicon to human capabilities and expectations.   So, documentation needs to go beyond the minimum from which an expert could deduce the system behaviour.  It needs to point out unexpected things that a competent programmer might miss, even if they could potentially have deduced that unexpected behaviour.

The trouble here is that the syntax of a generator is so much like a function that it's easy to think of it as being as safe and simple as a function.  It's not: the "yield" statement lets a lot of external complexity leak in that's not relevant to a function (unless you're writing multithreaded code).  So, the documentation needs to help the user avoid such problems.

----------

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


More information about the Python-bugs-list mailing list