I am still confused about what first-class functions are. If I understand correctly, first-class functions should use one function as an object. Is this correct?
Is this a first-class function?
def this_is_example(myarg1):
return myarg1
def this_is_another_example(myarg):
return this_is_example(myarg) + myarg
this_is_another_example(1)
A first-class function is not a particular kind of function. All functions in Python are first-class functions. To say that functions are first-class in a certain programming language means that they can be passed around and manipulated similarly to how you would pass around and manipulate other kinds of objects (like integers or strings). You can assign a function to a variable, pass it as an argument to another function, etc. The distinction is not that individual functions can be first class or not, but that entire languages may treat functions as first-class objects, or may not.