
Aug. 27, 2003
3:57 a.m.
I have no idea what the issues are w.r.t. cleanup for generators, but wouldn't it be more natural to make sure that the finally clause would be executed when the generator is garbage collected?
The problem is that the language definition doesn't define *when* GC happens, if at all. E.g. in Jython this depends on the Java GC. And even in CPython, it's easily conceivable that an accidental cycle in the user data structures prevents collection. So there is a need for explicit control in some cases.
Back to lurking,
Good idea. :-) --Guido van Rossum (home page: http://www.python.org/~guido/)