Return a Function

A return statement can return another function from a function.

Example:

# first method
def calculate(a,b):
    x = a + b
    y = a - b
    #second method
    return lambda: print ( x * y)

# generate a object of first method
returned_calculate_funcation = calucate(10,5)

# print object
print(returned_calculate_funcation)

# call second method by first method
returned_calculate_funcation()

Output

< Object reference >
75


Related Tutorials