On 2021-10-03 10:39:38 +1100, Chris Angelico wrote:
> # Oh, and it doesn't actually assign anything.
> >>> def f(n):
> ... return (lambda: (n := 1)), (lambda: n)
> ...
> >>> g, h = f(5)
> >>> h()
> 5
> >>> g()
> 1
> >>> h()
> 5
I thought about that one a bit more and I think that the lambda is
On 2021-10-03 10:39:38 +1100, Chris Angelico wrote:
> Using assignment expressions in lambda functions sometimes works, but
> sometimes doesn't.
> ... return lambda x: (x, x := 2, x)
syntax ok
> return lambda: n := 1
syntax error
> ... return lambda: (n := 1)
syntax ok
> return