First-Class Functions
Functions and nested-functions in Python.
We'll cover the following...
We'll cover the following...
Function: A first-class object
A first-class object is an object that can be:
- Created at runtime (assigned to a variable)
- Stored in a data structure
- Passed as an argument to another function
- Returned as a value from another function
Several data types in Python are first-class objects, e.g. int, string, etc. But that’s not it. Functions in Python are also first-class objects. Without any further ado, let us run a program demonstrating the nature of functions as first-class objects.
In the above code, in the beginning, we make ...