[Python-Dev] Generator objects and list comprehensions?
Lukasz Langa
lukasz at langa.pl
Fri Feb 3 01:21:10 EST 2017
More information about the Python-Dev mailing list
Fri Feb 3 01:21:10 EST 2017
- Previous message (by thread): [Python-Dev] Generator objects and list comprehensions?
- Next message (by thread): [Python-Dev] Summary of Python tracker Issues
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 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. - Ł
- Previous message (by thread): [Python-Dev] Generator objects and list comprehensions?
- Next message (by thread): [Python-Dev] Summary of Python tracker Issues
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list