Message128842
When you have a generator as an argument to zip(), code after the last yield statement may not get executed. The problem is that zip() stops after it gets _one_ exception, i.e. when just one of the generators has finished.
As a result, if there were any important clean-up code at the end of a generator, it will not be executed. Caches may not get flushed, et cetera.
At the least, this is a documentation bug that needs to be pointed out in both zip() and the definition of a generator(). More realistically, it is a severe wart on the language, because it violates the programmer's reasonable expectation that a generator executes until it falls off the end of the function. It means that a generator becomes conceptually nasty: you cannot predict what it will do based just on an inspection of the code and the code it calls.
Likely, the same behavior happens in itertools, too. |
|
Date |
User |
Action |
Args |
2011-02-19 10:50:45 | gpk-kochanski | set | recipients:
+ gpk-kochanski |
2011-02-19 10:50:45 | gpk-kochanski | set | messageid: <1298112645.15.0.0904865308119.issue11248@psf.upfronthosting.co.za> |
2011-02-19 10:50:44 | gpk-kochanski | link | issue11248 messages |
2011-02-19 10:50:44 | gpk-kochanski | create | |
|