[Python-Dev] Tricky way of of creating a generator via a comprehension expression (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 22 23:44:58 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 ]
Ivan Levkivskyi wrote:
The key idea is that neither comprehensions nor generator expressions should create a function scope surrounding the
expr
I don't see how you can avoid an implicit function scope in the case of a generator expression, though. And I can't see how to make yield in a generator expression do anything sensible.
Consider this:
def g():
return ((yield i) for i in range(10))
Presumably the yield should turn g into a generator, but... then what? My brain is hurting trying to figure out what it should do.
-- 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 ]