Use lambda to define inner function : Function Inner « Function « Python
- Python
- Function
- Function Inner
Use lambda to define inner function

def func():
x = 4
action = (lambda n: x ** n) # x in enclosing def
return action
x = func()
print x(2) # prints 16
Related examples in the same category