Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81a15ea

Browse files
authored
gh-101100: Further improve docs on function attributes (#113001)
1 parent9560238 commit81a15ea

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

‎Doc/c-api/function.rst

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 3 deletions
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)

[8]ページ先頭

©2009-2025 Movatter.jp