[Python-ideas] Using yield inside a comprehension.

Jonathan Slenders jonathan at slenders.be
Tue Nov 26 14:54:32 CET 2013


Where do I find the PEP that describes that the following statement assigns
a generator object to `values`?
values = [ (yield x) for x in range(10) ]

I assume it's equivalent to the following:
values = (x for x in range(10))


The reason for asking this is that I see no point in using the first syntax
and that the first has another meaning in Python 2.7, if used inside a
function.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131126/e62d81f6/attachment.html>


More information about the Python-ideas mailing list