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

Nick Coghlan ncoghlan at gmail.com
Sat Nov 25 19:57:48 EST 2017


On 26 November 2017 at 02:59, Guido van Rossum <guido at python.org> wrote:
>
> I'd be happy to stop with the conclusion that we're going to rip out some
> confusing syntax rather than trying to generate code for it -- IMO we've
> proved to ourselves that this stuff is too complicated to be useful.

I'll also note that even if we go through a period of deprecating and
then prohibiting the syntax entirely, we'll still have the option of
bringing support for "yield" in comprehensions back later with
deliberately designed semantics (as happened for "await" in
https://www.python.org/dev/peps/pep-0530/#await-in-comprehensions), as
opposed to the accident-of-implementation semantics they have now.

It may also turn out that as more asynchronous code is able to switch
to being 3.6+ only, allowing "await" and prohibiting "yield" will
prove to be sufficient for all practical purposes (as even the "yield
from" based spelling is Python-3-only, so it's only code that still
has to support 3.3, 3.4, 3.5, without needing to support 2.7, that
could use "yield from + yield" comprehensions, but wouldn't have the
option of just switching to async+await instead).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list