[Python-ideas] combine for/with statement
Carl Matthew Johnson
cmjohnson.mailinglist at gmail.com
Wed Aug 3 03:41:11 CEST 2011
On Aug 2, 2011, at 3:11 PM, Mark McDuff wrote:
> I find that I am often writing code in the following pattern:
>
> foo = MyContextManager(*args)
> for bar in my_iter:
> with foo:
> # do stuff
>
> I think it would be much cleaner to be able to write:
>
> for bar in my_iter with MyContextManager(*args):
> # do stuff
It's not clear to me whether that means
> for bar in my_iter:
> with MyContextManager(*args):
> # do stuff
or
> with MyContextManager(*args):
> for bar in my_iter:
> # do stuff
-0.
More information about the Python-ideas
mailing list