erikrose/more-itertools — pull request #18 by abarnert (2012-11-17 00:28:20+00:00)
Title: Add with_iter.

- Wraps an iterable in a with statement, so it closes when consumed.

The idea is that you can, e.g., use a file in a generator expression, and the file will be closed when the generator is fully consumed (or closed or deleted). So, you can pass that generator to an async call, knowing the file will be closed at the appropriate time.

It works for any object which is both an iterable and a contextmanager.