[Python-Dev] Tricky way of of creating a generator via a comprehension expression (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Nov 22 09:46:43 EST 2017
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 22 Nov 2017 15:15:49 +0100 Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
There are many things that I would reject in code review, but they are still allowed in Python, this is one of the reasons why code reviews exist. Also I am not sure how
yield
in a comprehension is more tricky thanawait
in a comprehension.
I am not sure either, but do note that "yield" and "await" are two different things with different semantics, so allowing "await" while disallowing "yield" wouldn't strike me as inconsistent.
The exact semantics of "yield" inside a comprehension is a common source of surprise or bewilderment, and the only actual use I've seen of it is to show it off as a "clever trick". So instead of fixing (and perhaps complicating) the implementation to try and make it do the supposedly right thing, I am proposing to simply disallow it so that we are done with the controversy :-)
Regards
Antoine.
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]