diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-12-11 10:00:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 10:00:42 (GMT) |
commit | 4c5b9c107a1d158b245f21a1839a2bec97d05383 (patch) | |
tree | bc05370d987d9131f6dd0729fb17079f9b03fb7d /Doc/howto | |
parent | 9cdf05bc28c5cd8b000b9541a907028819b3d63e (diff) | |
download | cpython-4c5b9c107a1d158b245f21a1839a2bec97d05383.zip cpython-4c5b9c107a1d158b245f21a1839a2bec97d05383.tar.gz cpython-4c5b9c107a1d158b245f21a1839a2bec97d05383.tar.bz2 |
gh-101100: Improve documentation on function attributes (#112933)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Doc/howto')
-rw-r--r-- | Doc/howto/annotations.rst | 3 | ||||
-rw-r--r-- | Doc/howto/descriptor.rst | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/Doc/howto/annotations.rst b/Doc/howto/annotations.rst index 1134686..be8c7e6 100644 --- a/Doc/howto/annotations.rst +++ b/Doc/howto/annotations.rst @@ -153,7 +153,8 @@ on an arbitrary object ``o``: unwrap it by accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you have found the root unwrapped function. * If ``o`` is a callable (but not a class), use - ``o.__globals__`` as the globals when calling :func:`eval`. + :attr:`o.__globals__ <function.__globals__>` as the globals when calling + :func:`eval`. However, not all string values used as annotations can be successfully turned into Python values by :func:`eval`. diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index f732aae..87274a5 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -1342,7 +1342,8 @@ Using the non-data descriptor protocol, a pure Python version of The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute that refers to the underlying function. Also it carries forward the attributes necessary to make the wrapper look like the wrapped -function: ``__name__``, ``__qualname__``, ``__doc__``, and ``__annotations__``. +function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, +:attr:`~function.__doc__`, and :attr:`~function.__annotations__`. .. testcode:: :hide: @@ -1522,8 +1523,9 @@ Using the non-data descriptor protocol, a pure Python version of The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a ``__wrapped__`` attribute that refers to the underlying function. Also it carries forward the attributes necessary to make the wrapper look -like the wrapped function: ``__name__``, ``__qualname__``, ``__doc__``, -and ``__annotations__``. +like the wrapped function: :attr:`~function.__name__`, +:attr:`~function.__qualname__`, :attr:`~function.__doc__`, +and :attr:`~function.__annotations__`. Member objects and __slots__ |