Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Functions as Objects

In Python, functions are first-class objects — they can be used anywhere any other object can. See First-class function — Wikipedia.

What this means

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

Higher-order functions

A function that takes or returns another function. apply(f, x, y) and compose(f, g) are examples here.

Run

python functions_as_objects.py