3 ms·
> For example you can't do `foo = (yield a).b` you have to do `x = yield a; foo = x.b`. The first snippet actually works fine. Yield expressions were introduce
by ptx 3y ago
> For example you can't do `foo = (yield a).b` you have to do `x = yield a; foo = x.b`.
The first snippet actually works fine. Yield expressions were introduced with PEP 342 in Python 2.5.
- IshKebab 3y agoAh I misremembered. I was actually trying to do this x = [yield a for a in b] Which yields (heh) an `Invalid Syntax` error. Thanks for the link to that PEP though - turns out the answer is that you almost always have to parenthesise it. x = [(yield a) for a in b] > SyntaxError: yield inside list comprehension Ok my original point stands.