Website hosting service by Active-Venture.com
  

 Back to Index


2.3.9.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 namespace (this is the same as m.__dict__ where m is the module in which the function f was defined).

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.

Functions have another special attribute f.__dict__ (a.k.a. f.func_dict) which contains the namespace used to support function attributes. __dict__ and func_dict can be accessed directly or set to a dictionary object. A function's dictionary cannot be deleted.

 

  

 

© 2002-2004 Active-Venture.com Webhosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Cheap domain registration : Register domain name or buy domain name, including free domain hosting services

 
Active-Domain.com offers cheap domain registration, domain name transfer and domain search services    

Domain registration : Buy domain name or register domain name from $5.95/year only