[Python-Dev] Generator objects and list comprehensions?

Anders Munch ajm at flonidan.dk
Thu Feb 2 05:17:57 EST 2017


Craig Rodrigues <rodrigc at freebsd.org>:
> Make this return a list on Python 3, like in Python 2:  [(yield 1) for x in range(10)] 

Give Python 2 a little more credit.

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> [(yield 1) for x in range(10)]
  File "<stdin>", line 1
SyntaxError: 'yield' outside function

regards, Anders



More information about the Python-Dev mailing list