On Jul 12, 2019, at 06:27, haael <[email protected]> wrote:
> 
> Tuple as context manager would invoke __enter__ for each of its elements and 
> return a tuple of the results.
> 
> On exit, the __exit__ method would be invoked for every element.
> 
> We could even generalize it to every kind of iterable.

So instead of exiting them in reverse order, it would exit them in order of 
entry?

And how would you generalize it to every kind of itetable? Even iterators? Then 
the enter will exhaust the iterator, so the exit won’t see anything.

Also, what does it do if one of the elements raises on entry, or on exit?

ExitStack answers all of these problems. Maybe the solution is just to make it 
slightly easier to use ExitStack with an iterable of context managers, and a 
lot easier for novices to discover it?


_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/7X4BP2WSSQHJLNNTFYBIUCYIISQIPJQT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to