New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yield expression vs lambda #48998
Comments
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 |
Attaching patch? BTW, how did you find this bug? :) |
I didn't find it, but someone from the German Python webforum. :) Hmm, I wonder why lambda: (yield 1) alone doesn't give [1, None]. (That Anyway, perhaps yield in lambdas should be forbidden. |
On Sat, Dec 27, 2008 at 11:41 AM, Georg Brandl <report@bugs.python.org> wrote:
Actually, I don't think the return value should even make it's way to
Probably too late now for 2.x and 3.x. |
Yes, I think so too. I just wondered at the seemingly inconsistent
Right. I'd say go for applying the patch. |
Fixed in r67954. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: