FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.12] gh-101100: Further improve docs on function attributes (GH-113001) by miss-islington · Pull Request #113030 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Doc/c-api/function.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ There are a few functions specific to Python functions.
must be a dictionary with the global variables accessible to the function.

The function's docstring and name are retrieved from the code object.
:func:`~function.__module__`
:attr:`~function.__module__`
is retrieved from *globals*. The argument defaults, annotations and closure are
set to ``NULL``. :attr:`~function.__qualname__` is set to the same value as
the code object's :attr:`~codeobject.co_qualname` field.
Expand Down
9 changes: 6 additions & 3 deletions Doc/reference/datamodel.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down

Back | FazBrowse Home | New Git URL