Message128889
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. |
|
Date |
User |
Action |
Args |
2011-02-20 01:41:44 | gpk-kochanski | set | recipients:
+ gpk-kochanski, georg.brandl, rhettinger, ezio.melotti, eric.araujo, daniel.urban, docs@python |
2011-02-20 01:41:44 | gpk-kochanski | set | messageid: <1298166104.1.0.316331314972.issue11248@psf.upfronthosting.co.za> |
2011-02-20 01:41:43 | gpk-kochanski | link | issue11248 messages |
2011-02-20 01:41:43 | gpk-kochanski | create | |
|