[Python-Dev] Tricky way of of creating a generator via a comprehension expression (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Sat Nov 25 18:45:56 EST 2017
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Serhiy Storchaka wrote:
Ivan explained that this function should be rough equivalent to
def f(): t = [(yield i) for i in range(3)] return (x for x in t) This is a rough equivalent. There are differences in details.
The details would seem to be overwhelmingly important, though.
I take it you're saying the semantics should be "like the above except that the returned iterator is lazy". But that seems impossible, because f() can't return anything until it finishes having all its values sent to it.
-- Greg
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]