In Python, functions are first-class objects — they can be used anywhere any other object can. See First-class function — Wikipedia.
A function can be:
- Assigned to a variable
- Stored in a list or dictionary
- Used as an attribute of an object
- Passed as an argument to another function
- Returned as the result of a function call
A function that takes or returns another function. apply(f, x, y) and compose(f, g) are examples here.
python functions_as_objects.py