On Wed, 17 Apr 2019 at 00:45, Steven D'Aprano wrote:
> I don't know. You tell us -- why do you care about the StopIteration
> value in a for-loop?
I came across the idea while I was reading various PEPs, so I don't
have an actual use case under my hands right now. However, in the past
I had a
I don't like it either. Ideally, I would want "returning", but of
course a new keyword is not an option for such limited use case.
"as" is probably much better, and the behavior of as in other contexts
is very similar.
On Tue, 16 Apr 2019 at 23:42, Jan Kaliszewski wrote:
>
> Hello,
>
>
On 4/16/2019 4:54 PM, Stefano Borini wrote:
given the following code
def g():
yield 2
yield 3
return 6
for x in g():
print(x)
The output is obviously
2
3
As far as I know, there is currently no way to capture the
StopIteration value when the generator is used in a for
Jan Kaliszewski wrote:
I like the idea -- occasionally (when dealing with `yield
from`-intensive code...) I wish such a shortcut existed.
Can you give a concrete example of a use case?
--
Greg
___
Python-ideas mailing list
Python-ideas@python.org
On Tue, Apr 16, 2019 at 09:54:31PM +0100, Stefano Borini wrote:
> As far as I know, there is currently no way to capture the
> StopIteration value when the generator is used in a for loop. Is it
> true?
I think you are correct. See
https://bugs.python.org/issue35756
> If not, would a syntax
Hello,
2019-04-16 Stefano Borini dixit:
> def g():
> yield 2
> yield 3
> return 6
[...]
> for x in g() return v:
> print(x)
>
> print(v) # prints 6
I like the idea -- occasionally (when dealing with `yield
from`-intensive code...) I wish such a shortcut existed.
I don't like
given the following code
def g():
yield 2
yield 3
return 6
for x in g():
print(x)
The output is obviously
2
3
As far as I know, there is currently no way to capture the
StopIteration value when the generator is used in a for loop. Is it
true?
If not, would a syntax like:
for x