4 ms·
Are you saying that a non-mutating variant of the above works? For instance: foo.on_click(lambda:x func(x, whatever))
by kazinator 10y ago
Are you saying that a non-mutating variant of the above works? For instance:
foo.on_click(lambda:x func(x, whatever))
- dragonwriter 10y agoyeah, 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.