Y
Hacker News
new
|
ask
|
show
|
jobs
by
kazinator
3427 days ago
Are you saying that a non-mutating variant of the above works? For instance:
foo.on_click(lambda:x func(x, whatever))
1 comments
dragonwriter
3427 days ago
yeah, except that the syntax is
lambda x: func(x, whatever)
In fact, if x is an object that stores a mutable numeric cell, you could even do a mutating:
lambda x: x.add(1)
Mutation isn't prohibited in Python lambdas, statements (including assignments, which are statements rather than expressions in Python), however, are.
link