[Python-ideas] unpacking context managers in WITH statement
Yury Selivanov
yselivanov.ml at gmail.com
Fri Feb 3 19:11:03 CET 2012
Ah, yes, my bad. Then I'm +1 on that one ;)
On 2012-02-03, at 1:09 PM, Michael Foord wrote:
>
>
> On 3 February 2012 18:06, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> On 2012-02-03, at 12:50 PM, Michael Foord wrote:
>
> > with *ctxs as tuple_of_results:
>
> This is not necessary, as 'ctxs' already holds all instances of
> all context managers; so the 'ctxs' would be equal to 'tuple_of_results'
>
> The results are whatever is returned by ctx.__enter__(), not the context manager itself.
>
> Michael
>
>
> > with *ctx, other as tuple_of_results, another:
> > ...
>
> Looks useful to me.
>
> -
> Yury
>
>
>
> --
> http://www.voidspace.org.uk/
>
> May you do good and not evil
> May you find forgiveness for yourself and forgive others
>
> May you share freely, never taking more than you give.
>
> -- the sqlite blessing http://www.sqlite.org/different.html
>
More information about the Python-ideas
mailing list