[Python-Dev] Generator objects and list comprehensions?

Craig Rodrigues rodrigc at freebsd.org
Wed Jan 25 00:38:44 EST 2017


Hi,

Glyph pointed this out to me here:
http://twistedmatrix.com/pipermail/twisted-python/2017-January/031106.html

If I do this on Python 3.6:

>>  [(yield 1) for x in range(10)]
<generator object <listcomp> at 0x10cd210f8>

If I understand this:
https://docs.python.org/3/reference/expressions.html#list-displays
then this is a list display and should give a list, not a generator object.
Is there a bug in Python, or does the documentation need to be updated?

--
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170124/117a2eb4/attachment.html>


More information about the Python-Dev mailing list