Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Michael Selik
On Wed, Jun 29, 2016 at 7:11 AM Victor Savu wrote: > Please let me know if you are interested in a more concrete case such as a > domain-specific application (I can think of progress bars, logging, > transfer rate statistics ...). > Yes, please. I'd like to compare the proposed syntax against th

Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Victor Savu
Sure. Simple use-case: Decorate the yielded values and the return value of a generator. Right now, with `yield from` you can only decorate the return value, whereas with a for loop you can decorate the yielded values, but you sacrifice the returned value altogether. ``` def ret_decorator(target_g

Re: Language improvement: Get more from the `for .. else` clause

2016-06-27 Thread Michael Selik
On Mon, Jun 27, 2016 at 12:53 AM Victor Savu wrote: > capture the [StopIteration] value in the `else` statement of the `for` loop > I'm having trouble thinking of a case when this new feature is necessary. Can you show a more realistic example? -- https://mail.python.org/mailman/listinfo/python

Language improvement: Get more from the `for .. else` clause

2016-06-26 Thread Victor Savu
tl;dr: 1. Add `StopAsyncIteration.value`, with the same semantic as `StopIteration.value` (documented in PEP 380). 2. Capture `StopIteration.value` and StopAsyncIteration.value in the `else` clauses of the `for` and `async for` statements respectively. Note: I already have a pr