3 ms·
foo = lambda x: lambda y: x + y bar = foo(10) This is perfectly correct Python code too if you prefer. The only real thing with Python's lambdas is that, beca
by cyrus_ 15y ago
foo = lambda x: lambda y: x + y
bar = foo(10)
This is perfectly correct Python code too if you prefer. The only real thing with Python's lambdas is that, because Python makes a distinction between statements and expressions, you can't easily do things like use temporary variables inside a lambda, but cases like that are rare and are typically more readable with a separate standalone function definition anyway.