Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:
You somehow must tell the iterator that you are done with it.
This is best done by a del c in your first snippet, since c is the
last reference to the iterator.
To do this in a function (or a context manager), the trick is to wrap
the
Raymond Hettinger [EMAIL PROTECTED] added the comment:
Sorry, am going to reject this. The use cases are somewhat uncommon
and I don't want to clutter-up tools that need to remain as simple as
possible. The pure python code for chain() is so simple that it's not
hard to roll your own version
New submission from Bruce Frederiksen [EMAIL PROTECTED]:
There is no way to get generators to clean up (run their 'finally'
clause) when used as an inner iterable to chain:
def gen(n):
... try:
... # do stuff yielding values
... finally:
... # clean up
c =
Changes by Benjamin Peterson [EMAIL PROTECTED]:
--
assignee: - rhettinger
nosy: +rhettinger
versions: +Python 2.7, Python 3.1 -Python 3.0
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3842
___