A user-defined function object is created by a function definition (see def). It should be called with an argument list containing the same number of items as the function's formal parameter list.

Special attributes:

Most of the attributes labelled Writable check the type of the assigned value.

Changed in version 2.4: func_name is now writable.

Function objects also support getting and setting arbitrary attributes, which can be used, for example, to attach metadata to functions. Regular attribute dot-notation is used to get and set such attributes. Note that the current implementation only supports function attributes on user-defined functions. Function attributes on built-in functions may be supported in the future.

Additional information about a function's definition can be retrieved from its code object (see type-code).