Next: Methods Prev: Classes and Class Instances Up: Other Built-in Types Top: Top

2.1.7.3. Functions.

Function objects are created by function definitions. The only operation on a function object is to call it: func(argument-list).

There are really two flavors of function objects: built-in functions and user-defined functions. Both support the same operation (to call the function), but the implementation is different, hence the different object types.

The implementation adds two special read-only attributes: f.func_code is a function's code object (see below) and f.func_globals is the dictionary used as the function's global name space (this is the same as m.__dict__ where m is the module in which the function f was defined).