I read this question
How does this understanding of lambda / yield / generator work?
I would like to understand the language constructs in more detail. Why are parentheses needed?
(yield 55)
Unlike
yield 55
Why does it only work in a generator expression when it is passed as an argument to a function? If I do the following
a = lambda x: 1 a((yield 55)) SyntaxError: 'yield' outside function
At startup:
a = lambda x: 1 list(a((yield 55)) for b in range(5)) [55, 1, 55, 1, 55, 1, 55, 1, 55, 1]
Why does this make a difference? Who is calling next? The order of evaluation is not clear on the syntax.
Har
source share