P.J. Eby wrote: > Of course, at that point, what's the difference between: > > with foo() as bar: > baz > > and... > > �...@foo > def bar(): > baz > > except for being slightly less verbose? (due to missing nonlocal statements, > etc.)
That's not quite direct translation. Closer would be: @foo() def _(bar): baz del _ since the "bar" of the with statement is injected into the namespace of the block. (Obviously, the foo would have be implemented differently in the two cases in order to have it operate the same way.) I have thought about suggesting adding control flow to the with statement before, since I think if done properly, it might be able to negate the desire people have for multi-line lambdas/Ruby-style blocks, but I do wonder if it would be too confusing to have "with" sometimes mean "abstracting error handling code" and other times mean "abstracted control flow." But now it looks like there's no way around using the with-statement for control flow, since sometimes the block needs to be skipped anyway. So, I'm +.5 on the idea. -- Carl _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com