[Terry Reedy <[email protected]>]
> ...
> If I am understanding correctly, this would also let one *intentionally
> 'leak' (export) the last value of the loop variable when wanted.
>
> [math.log(xlast:=x) for x in it if x > 0]
> print(xlast)
Yup! You can do that today by emulating a nonlocal "cell" reference,
but I don't recommend it ;-)
xlast_cell = [None]
[math.log(x) for x in it if x > 0
for xlast_cell[0] in [x]]
print(xlast_cell[0])
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/