[New-bugs-announce] [issue4748] yield expression vs lambda

Georg Brandl report at bugs.python.org
Fri Dec 26 10:57:41 CET 2008


New submission from Georg Brandl <georg at python.org>:

With lambda, the ban on "return x" in generators can be evaded:

>>> x = lambda: ((yield 1), (yield 2))
>>> list(x())
[1, 2, (None, None)]
>>> dis.dis(x)
  1           0 LOAD_CONST               0 (1)
              3 YIELD_VALUE
              4 LOAD_CONST               1 (2)
              7 YIELD_VALUE
              8 BUILD_TUPLE              2
             11 RETURN_VALUE

----------
messages: 78291
nosy: georg.brandl
priority: high
severity: normal
status: open
title: yield expression vs lambda
versions: Python 2.6, Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4748>
_______________________________________


More information about the New-bugs-announce mailing list