Skip to content

Commit f45fd81

Browse files
AlexWaygoodaisk
authored andcommitted
pythongh-101100: Further improve docs on function attributes (python#113001)
1 parent 85397f7 commit f45fd81

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Doc/c-api/function.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ There are a few functions specific to Python functions.
3535
must be a dictionary with the global variables accessible to the function.
3636
3737
The function's docstring and name are retrieved from the code object.
38-
:func:`~function.__module__`
38+
:attr:`~function.__module__`
3939
is retrieved from *globals*. The argument defaults, annotations and closure are
4040
set to ``NULL``. :attr:`~function.__qualname__` is set to the same value as
4141
the code object's :attr:`~codeobject.co_qualname` field.

Doc/reference/datamodel.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ Most of these attributes check the type of the assigned value:
601601
or ``None`` if unavailable.
602602

603603
* - .. attribute:: function.__defaults__
604-
- A :class:`tuple` containing default parameter values
604+
- A :class:`tuple` containing default :term:`parameter` values
605605
for those parameters that have defaults,
606606
or ``None`` if no parameters have a default value.
607607

@@ -614,19 +614,22 @@ Most of these attributes check the type of the assigned value:
614614
See also: :attr:`__dict__ attributes <object.__dict__>`.
615615

616616
* - .. attribute:: function.__annotations__
617-
- A :class:`dictionary <dict>` containing annotations of parameters.
617+
- A :class:`dictionary <dict>` containing annotations of
618+
:term:`parameters <parameter>`.
618619
The keys of the dictionary are the parameter names,
619620
and ``'return'`` for the return annotation, if provided.
620621
See also: :ref:`annotations-howto`.
621622

622623
* - .. attribute:: function.__kwdefaults__
623624
- A :class:`dictionary <dict>` containing defaults for keyword-only
624-
parameters.
625+
:term:`parameters <parameter>`.
625626

626627
* - .. attribute:: function.__type_params__
627628
- A :class:`tuple` containing the :ref:`type parameters <type-params>` of
628629
a :ref:`generic function <generic-functions>`.
629630

631+
.. versionadded:: 3.12
632+
630633
Function objects also support getting and setting arbitrary attributes, which
631634
can be used, for example, to attach metadata to functions. Regular attribute
632635
dot-notation is used to get and set such attributes.

0 commit comments

Comments
 (0)