-1
On Wed, Aug 3, 2011 at 11:56 AM, Nick Coghlan
On Wed, Aug 3, 2011 at 11:11 AM, 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
I'm not sure why you think putting the context manager way over on the right hand side is an improvement, but no, merging arbitrary statements is never going to happen (even the comprehension inspired merging of for and if statements has been explicitly rejected many many times).
As Carl notes, the ambiguity of the propose syntax is also not good - it is unclear whether the context manager is recreated on each pass around the loop, reused on each pass, or applied once to cover the entire loop operation.
Cheers, Nick.
-- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia _______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas