[Python-Dev] Tricky way of of creating a generator via a comprehension expression

Serhiy Storchaka storchaka at gmail.com
Thu Nov 23 07:17:32 EST 2017


23.11.17 13:49, Antoine Pitrou пише:
> I'm still in favour of deprecating and then disallowing.

We could disallow it without deprecation. The current behavior 
definitely is wrong, nobody should depend on it. It should be either 
fixed or disallowed.

> Nobody seems
> to have presented a real-world use case that is made significantly
> easier by trying to "fix" the current behaviour (as opposed to
> spelling the loop explicitly).  I do asynchronous programming using
> "yield" every day in may job (because of compatibility requirements
> with Python 2) and I've never had once the need to write a "yield"
> inside a comprehension or generator expression.

I used the "yield" statement, but I never used the "yield" expressions. 
And I can't found examples. Could you please present a real-world use 
case for the "yield" (not "yield from") expression?



More information about the Python-Dev mailing list