A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-February/147332.html below:

[Python-Dev] Generator objects and list comprehensions?

[Python-Dev] Generator objects and list comprehensions?Lukasz Langa lukasz at langa.pl
Fri Feb 3 01:21:10 EST 2017
> On Feb 2, 2017, at 2:17 AM, Anders Munch <ajm at flonidan.dk> wrote:
> 
> Give Python 2 a little more credit.

We are, it told you what your issue was: yield outside a function. Consider:

  >>> def f():
  ...   l = [(yield 1) for x in range(10)]
  ...   print(l)
  >>> gen = f()
  >>> for i in range(11):
  ...   gen.send(i or None)
  ...
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

But this is a very convoluted "feature" and likely people don't expect *this* to be what's happening.

- Ł
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4