On Mon, Oct 15, 2012 at 10:31 PM, Calvin Spealman ironfroggy@gmail.com wrote:
Currently, "with yield expr:" is not valid syntax, surprisingly.
It's not that surprising, it's the general requirement that yield expressions must be enclosed in parentheses except when used standalone or in a simple assignment statement.
"with (yield expr):" is valid syntax though, so I'm reluctant to endorse doing anything substantially different if the parentheses are omitted.
I think the combination of "yield from" to delegate control (including exception handling) completely to a subgenerator and "context manager + for loop + explicit yield" when an operation needs to yield multiple times and the exception handling behaviour should be left to the caller (as in the "as_completed" case) should cover the necessary behaviours.
Cheers, Nick.