[Phillip J. Eby]the only way a generator-iterator can become > part of a cycle is via an action taken outside the generator. (E.g. > passing it into itself via 'continue', creating a link from one of its > arguments to it, etc.) So, it's probably not a terrible limitation in > practice.
It's enough to store a reference to the generator in a global (or in anything that's reachable from a global). The generator's frame's f_globals pointer then ensures the cycle. Throwing an exception also provides ample opportunity for creating cycles, since the frame hold a reference to the most recent traceback. Ironically, throwing an exception with a traceback into a generator is likely to cause a cycle because the traceback likely references the throwing frame, which certainly has a reference to the generator... -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com