Well to be technically correct it is not the garbage collector but the reference counting in python (the garbage collector is mainly for cleaning up unreachable cyclic stuff and is only run once in the so many times, while destruction after a reference count dropped to zero is done immediate even when garbage collection is disabled). A demonstration of how it works even when you disable garbage collection.
import gc gc.disable() def generator(): try: while True: yield 1 finally: print 'done' generator().next() When executing the above I get: done 1 Wich means that since the created generator is no longer referenced after having executed generator().next() it gets destroyed, causing the finally statement to get executed. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org