diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-12-12 20:21:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 20:21:12 (GMT) |
commit | 81a15ea74e2607728fceb822dfcc1aabff00478a (patch) | |
tree | ba88fe81db6229647c6bdf60cf89a9be4928d599 /Doc/reference | |
parent | 956023826a393b5704d3414dcd01f1bcbeaeda15 (diff) | |
download | cpython-81a15ea74e2607728fceb822dfcc1aabff00478a.zip cpython-81a15ea74e2607728fceb822dfcc1aabff00478a.tar.gz cpython-81a15ea74e2607728fceb822dfcc1aabff00478a.tar.bz2 |
gh-101100: Further improve docs on function attributes (#113001)
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index de79d72..16ee3e3 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -601,7 +601,7 @@ Most of these attributes check the type of the assigned value: or ``None`` if unavailable. * - .. attribute:: function.__defaults__ - - A :class:`tuple` containing default parameter values + - A :class:`tuple` containing default :term:`parameter` values for those parameters that have defaults, or ``None`` if no parameters have a default value. @@ -614,19 +614,22 @@ Most of these attributes check the type of the assigned value: See also: :attr:`__dict__ attributes <object.__dict__>`. * - .. attribute:: function.__annotations__ - - A :class:`dictionary <dict>` containing annotations of parameters. + - A :class:`dictionary <dict>` containing annotations of + :term:`parameters <parameter>`. The keys of the dictionary are the parameter names, and ``'return'`` for the return annotation, if provided. See also: :ref:`annotations-howto`. * - .. attribute:: function.__kwdefaults__ - A :class:`dictionary <dict>` containing defaults for keyword-only - parameters. + :term:`parameters <parameter>`. * - .. attribute:: function.__type_params__ - A :class:`tuple` containing the :ref:`type parameters <type-params>` of a :ref:`generic function <generic-functions>`. + .. versionadded:: 3.12 + 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. |