> Currently this doesn't quite do what you might expect.
> It doesn't make the enclosing function into a generator,
> it make the list comprehension itself a generator:
>
>  >>> def f():
> ...  return [(yield x) for x in range(10)]
> ...
>  >>> g = f()
>  >>> g
> <generator object f.<locals>.<listcomp> at 0x6b396c>
>  >>>
>
>
Am I missing something: this is a syntax error for me in 3.8:

>>> def f():
...     return [(yield x) for x in range(10)]
...
  File "<stdin>", line 2
SyntaxError: 'yield' inside list comprehension
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BCVJ6RNH3G6YNYBUUOAIT62XEBG4DKXV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to