(original) (raw)
On 22 November 2017 at 15:46, Antoine Pitrou <solipsis@pitrou.net> wrote:
On Wed, 22 Nov 2017 15:15:49 +0100
Ivan Levkivskyi <levkivskyi@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 than \`await\` 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 :-)
Actually, I am not sure there is really a controversy, I have not yet met a person who \_expects\_
\`yield\` in a comprehension to work as it works now, instead everyone thinks it is just equivalent to a for-loop.
Anyway, I have some compromise idea, will send it in a separate e-mail.
--
Ivan