diff -r 181ced5bf0be Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst Mon Dec 02 05:53:35 2013 -0800 +++ b/Doc/reference/datamodel.rst Mon Dec 02 19:43:05 2013 +0000 @@ -487,43 +487,38 @@ | Attribute | Meaning | | +=======================+===============================+===========+ | :attr:`func_doc` | The function's documentation | Writable | - | | string, or ``None`` if | | + | :attr:`__doc__` | string, or ``None`` if | | | | unavailable | | +-----------------------+-------------------------------+-----------+ - | :attr:`__doc__` | Another way of spelling | Writable | - | | :attr:`func_doc` | | - +-----------------------+-------------------------------+-----------+ | :attr:`func_name` | The function's name | Writable | - +-----------------------+-------------------------------+-----------+ - | :attr:`__name__` | Another way of spelling | Writable | - | | :attr:`func_name` | | + | :attr:`__name__` | +-----------------------+-------------------------------+-----------+ | :attr:`__module__` | The name of the module the | Writable | | | function was defined in, or | | | | ``None`` if unavailable. | | +-----------------------+-------------------------------+-----------+ | :attr:`func_defaults` | A tuple containing default | Writable | - | | argument values for those | | + | :attr:`__defaults__` | argument values for those | | | | arguments that have defaults, | | | | or ``None`` if no arguments | | | | have a default value | | +-----------------------+-------------------------------+-----------+ | :attr:`func_code` | The code object representing | Writable | - | | the compiled function body. | | + | :attr:`__code__` | the compiled function body. | | +-----------------------+-------------------------------+-----------+ | :attr:`func_globals` | A reference to the dictionary | Read-only | - | | that holds the function's | | + | :attr:`__globals__` | that holds the function's | | | | global variables --- the | | | | global namespace of the | | | | module in which the function | | | | was defined. | | +-----------------------+-------------------------------+-----------+ | :attr:`func_dict` | The namespace supporting | Writable | - | | arbitrary function | | + | :attr:`__dict__` | arbitrary function | | | | attributes. | | +-----------------------+-------------------------------+-----------+ | :attr:`func_closure` | ``None`` or a tuple of cells | Read-only | - | | that contain bindings for the | | + | :attr:`__closure__` | that contain bindings for the | | | | function's free variables. | | +-----------------------+-------------------------------+-----------+ @@ -532,6 +527,12 @@ .. versionchanged:: 2.4 ``func_name`` is now writable. + .. versionchanged:: 2.6 + The double-underscore attributes ``__closure__``, ``__code__``, + ``__defaults__``, and ``__globals__`` were introduced as aliases for + the corresponding ``func_*`` attributes for forwards compatibility + with Python 3. + 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 @@ -542,16 +543,21 @@ code object; see the description of internal types below. .. index:: - single: func_doc (function attribute) single: __doc__ (function attribute) single: __name__ (function attribute) single: __module__ (function attribute) single: __dict__ (function attribute) + single: __defaults__ (function attribute) + single: __code__ (function attribute) + single: __globals__ (function attribute) + single: __closure__ (function attribute) + single: func_doc (function attribute) + single: func_name (function attribute) + single: func_dict (function attribute) single: func_defaults (function attribute) - single: func_closure (function attribute) single: func_code (function attribute) single: func_globals (function attribute) - single: func_dict (function attribute) + single: func_closure (function attribute) pair: global; namespace User-defined methods