3: The Function Object¶
Summary¶
Functions is Python are objects and can be used anywhere an object can
You can pass a function as a parameter and return a function result
Function parameters are passed by object reference, which means changes to parameters do not affect the variables used as arguments
Function s can have attributes defined which have a lifetime beyond that oof the functions local variables
Local variables exist only while the function is being executed, but attributes exist as long as the function object does
Lambda expressions are lightweight ways of creating function objects. They simplify the syntax for passing function arguments
Functions have variables which reference them rather than names
Functions can refer to their own attributes in code
A function object is an example of a callable