Callable Types

Functions

  • Defined with the def statement
     def foo(a):
         print "foo", a

Functions are just like any other object

     a = foo            # Variable assignment
     a(3)               # Call a function
     b = { }
     b['bar'] = foo     # Place in a dictionary
     b['bar'](10)       # Call the function

There are a number of callable objects

  • User defined functions
  • Built-in functions (implemented in C)
  • Class methods.
  • Classes
  • Consult reference for differences
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 42
July 17, 2000, beazley@cs.uchicago.edu
>>>