Skip to content

Commit 87dc028

Browse files
committed
Deploying to gh-pages from @ bff0132 🚀
1 parent 5fc0a01 commit 87dc028

File tree

533 files changed

+4364
-4410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

533 files changed

+4364
-4410
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 197adeeb7a95640cdeb8df01cd9b77c1
3+
config: c561900162b945c4ca541e6dcebecf2f
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_sources/library/contextlib.rst.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ Functions and classes provided:
106106

107107
This function is a :term:`decorator` that can be used to define a factory
108108
function for :keyword:`async with` statement asynchronous context managers,
109-
without needing to create a class or separate :meth:`__aenter__` and
110-
:meth:`__aexit__` methods. It must be applied to an :term:`asynchronous
109+
without needing to create a class or separate :meth:`~object.__aenter__` and
110+
:meth:`~object.__aexit__` methods. It must be applied to an :term:`asynchronous
111111
generator` function.
112112

113113
A simple example::
@@ -616,12 +616,12 @@ Functions and classes provided:
616616
asynchronous context managers, as well as having coroutines for
617617
cleanup logic.
618618

619-
The :meth:`close` method is not implemented, :meth:`aclose` must be used
619+
The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must be used
620620
instead.
621621

622622
.. coroutinemethod:: enter_async_context(cm)
623623

624-
Similar to :meth:`enter_context` but expects an asynchronous context
624+
Similar to :meth:`ExitStack.enter_context` but expects an asynchronous context
625625
manager.
626626

627627
.. versionchanged:: 3.11
@@ -630,16 +630,16 @@ Functions and classes provided:
630630

631631
.. method:: push_async_exit(exit)
632632

633-
Similar to :meth:`push` but expects either an asynchronous context manager
633+
Similar to :meth:`ExitStack.push` but expects either an asynchronous context manager
634634
or a coroutine function.
635635

636636
.. method:: push_async_callback(callback, /, *args, **kwds)
637637

638-
Similar to :meth:`callback` but expects a coroutine function.
638+
Similar to :meth:`ExitStack.callback` but expects a coroutine function.
639639

640640
.. coroutinemethod:: aclose()
641641

642-
Similar to :meth:`close` but properly handles awaitables.
642+
Similar to :meth:`ExitStack.close` but properly handles awaitables.
643643

644644
Continuing the example for :func:`asynccontextmanager`::
645645

_sources/library/inspect.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
492492
Methods implemented via descriptors that also pass one of the other tests
493493
return ``False`` from the :func:`ismethoddescriptor` test, simply because the
494494
other tests promise more -- you can, e.g., count on having the
495-
:ref:`__func__ <instance-methods>` attribute (etc) when an object passes
495+
:attr:`~method.__func__` attribute (etc) when an object passes
496496
:func:`ismethod`.
497497

498498

_sources/library/shelve.rst.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,14 @@ Restrictions
149149

150150
.. class:: BsdDbShelf(dict, protocol=None, writeback=False, keyencoding='utf-8')
151151

152-
A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`,
153-
:meth:`previous`, :meth:`last` and :meth:`set_location` which are available
154-
in the third-party :mod:`bsddb` module from `pybsddb
152+
A subclass of :class:`Shelf` which exposes :meth:`!first`, :meth:`!next`,
153+
:meth:`!previous`, :meth:`!last` and :meth:`!set_location` methods.
154+
These are available
155+
in the third-party :mod:`!bsddb` module from `pybsddb
155156
<https://www.jcea.es/programacion/pybsddb.htm>`_ but not in other database
156157
modules. The *dict* object passed to the constructor must support those
157158
methods. This is generally accomplished by calling one of
158-
:func:`bsddb.hashopen`, :func:`bsddb.btopen` or :func:`bsddb.rnopen`. The
159+
:func:`!bsddb.hashopen`, :func:`!bsddb.btopen` or :func:`!bsddb.rnopen`. The
159160
optional *protocol*, *writeback*, and *keyencoding* parameters have the same
160161
interpretation as for the :class:`Shelf` class.
161162

_sources/library/stdtypes.rst.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5325,25 +5325,30 @@ Methods
53255325
.. index:: pair: object; method
53265326

53275327
Methods are functions that are called using the attribute notation. There are
5328-
two flavors: built-in methods (such as :meth:`append` on lists) and class
5329-
instance methods. Built-in methods are described with the types that support
5330-
them.
5328+
two flavors: :ref:`built-in methods <builtin-methods>` (such as :meth:`append`
5329+
on lists) and :ref:`class instance method <instance-methods>`.
5330+
Built-in methods are described with the types that support them.
53315331

53325332
If you access a method (a function defined in a class namespace) through an
53335333
instance, you get a special object: a :dfn:`bound method` (also called
5334-
:dfn:`instance method`) object. When called, it will add the ``self`` argument
5334+
:ref:`instance method <instance-methods>`) object. When called, it will add
5335+
the ``self`` argument
53355336
to the argument list. Bound methods have two special read-only attributes:
5336-
``m.__self__`` is the object on which the method operates, and ``m.__func__`` is
5337+
:attr:`m.__self__ <method.__self__>` is the object on which the method
5338+
operates, and :attr:`m.__func__ <method.__func__>` is
53375339
the function implementing the method. Calling ``m(arg-1, arg-2, ..., arg-n)``
53385340
is completely equivalent to calling ``m.__func__(m.__self__, arg-1, arg-2, ...,
53395341
arg-n)``.
53405342

5341-
Like function objects, bound method objects support getting arbitrary
5343+
Like :ref:`function objects <user-defined-funcs>`, bound method objects support
5344+
getting arbitrary
53425345
attributes. However, since method attributes are actually stored on the
5343-
underlying function object (``meth.__func__``), setting method attributes on
5346+
underlying function object (:attr:`method.__func__`), setting method attributes on
53445347
bound methods is disallowed. Attempting to set an attribute on a method
53455348
results in an :exc:`AttributeError` being raised. In order to set a method
5346-
attribute, you need to explicitly set it on the underlying function object::
5349+
attribute, you need to explicitly set it on the underlying function object:
5350+
5351+
.. doctest::
53475352

53485353
>>> class C:
53495354
... def method(self):
@@ -5358,7 +5363,7 @@ attribute, you need to explicitly set it on the underlying function object::
53585363
>>> c.method.whoami
53595364
'my name is method'
53605365

5361-
See :ref:`types` for more information.
5366+
See :ref:`instance-methods` for more information.
53625367

53635368

53645369
.. index:: object; code, code object

_sources/reference/datamodel.rst.txt

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ These are the types to which the function call operation (see section
519519
:ref:`calls`) can be applied:
520520

521521

522+
.. _user-defined-funcs:
523+
522524
User-defined functions
523525
^^^^^^^^^^^^^^^^^^^^^^
524526

@@ -654,43 +656,64 @@ callable object (normally a user-defined function).
654656
single: __name__ (method attribute)
655657
single: __module__ (method attribute)
656658

657-
Special read-only attributes: :attr:`__self__` is the class instance object,
658-
:attr:`__func__` is the function object; :attr:`__doc__` is the method's
659-
documentation (same as ``__func__.__doc__``); :attr:`~definition.__name__` is the
660-
method name (same as ``__func__.__name__``); :attr:`__module__` is the
661-
name of the module the method was defined in, or ``None`` if unavailable.
659+
Special read-only attributes:
660+
661+
.. list-table::
662+
663+
* - .. attribute:: method.__self__
664+
- Refers to the class instance object to which the method is
665+
:ref:`bound <method-binding>`
666+
667+
* - .. attribute:: method.__func__
668+
- Refers to the original function object
669+
670+
* - .. attribute:: method.__doc__
671+
- The method's documentation (same as :attr:`!method.__func__.__doc__`).
672+
A :class:`string <str>` if the original function had a docstring, else
673+
``None``.
674+
675+
* - .. attribute:: method.__name__
676+
- The name of the method (same as :attr:`!method.__func__.__name__`)
677+
678+
* - .. attribute:: method.__module__
679+
- The name of the module the method was defined in, or ``None`` if
680+
unavailable.
662681

663682
Methods also support accessing (but not setting) the arbitrary function
664-
attributes on the underlying function object.
683+
attributes on the underlying :ref:`function object <user-defined-funcs>`.
665684

666685
User-defined method objects may be created when getting an attribute of a
667686
class (perhaps via an instance of that class), if that attribute is a
668-
user-defined function object or a class method object.
687+
user-defined :ref:`function object <user-defined-funcs>` or a
688+
:class:`classmethod` object.
689+
690+
.. _method-binding:
669691

670692
When an instance method object is created by retrieving a user-defined
671-
function object from a class via one of its instances, its
672-
:attr:`__self__` attribute is the instance, and the method object is said
673-
to be bound. The new method's :attr:`__func__` attribute is the original
674-
function object.
675-
676-
When an instance method object is created by retrieving a class method
677-
object from a class or instance, its :attr:`__self__` attribute is the
678-
class itself, and its :attr:`__func__` attribute is the function object
693+
:ref:`function object <user-defined-funcs>` from a class via one of its
694+
instances, its :attr:`~method.__self__` attribute is the instance, and the
695+
method object is said to be *bound*. The new method's :attr:`~method.__func__`
696+
attribute is the original function object.
697+
698+
When an instance method object is created by retrieving a :class:`classmethod`
699+
object from a class or instance, its :attr:`~method.__self__` attribute is the
700+
class itself, and its :attr:`~method.__func__` attribute is the function object
679701
underlying the class method.
680702

681703
When an instance method object is called, the underlying function
682-
(:attr:`__func__`) is called, inserting the class instance
683-
(:attr:`__self__`) in front of the argument list. For instance, when
704+
(:attr:`~method.__func__`) is called, inserting the class instance
705+
(:attr:`~method.__self__`) in front of the argument list. For instance, when
684706
:class:`!C` is a class which contains a definition for a function
685707
:meth:`!f`, and ``x`` is an instance of :class:`!C`, calling ``x.f(1)`` is
686708
equivalent to calling ``C.f(x, 1)``.
687709

688-
When an instance method object is derived from a class method object, the
689-
"class instance" stored in :attr:`__self__` will actually be the class
710+
When an instance method object is derived from a :class:`classmethod` object, the
711+
"class instance" stored in :attr:`~method.__self__` will actually be the class
690712
itself, so that calling either ``x.f(1)`` or ``C.f(1)`` is equivalent to
691713
calling ``f(C,1)`` where ``f`` is the underlying function.
692714

693-
Note that the transformation from function object to instance method
715+
Note that the transformation from :ref:`function object <user-defined-funcs>`
716+
to instance method
694717
object happens each time the attribute is retrieved from the instance. In
695718
some cases, a fruitful optimization is to assign the attribute to a local
696719
variable and call that local variable. Also notice that this
@@ -774,6 +797,8 @@ set to ``None`` (but see the next item); :attr:`__module__` is the name of
774797
the module the function was defined in or ``None`` if unavailable.
775798

776799

800+
.. _builtin-methods:
801+
777802
Built-in methods
778803
^^^^^^^^^^^^^^^^
779804

@@ -785,8 +810,9 @@ Built-in methods
785810
This is really a different disguise of a built-in function, this time containing
786811
an object passed to the C function as an implicit extra argument. An example of
787812
a built-in method is ``alist.append()``, assuming *alist* is a list object. In
788-
this case, the special read-only attribute :attr:`__self__` is set to the object
789-
denoted by *alist*.
813+
this case, the special read-only attribute :attr:`!__self__` is set to the object
814+
denoted by *alist*. (The attribute has the same semantics as it does with
815+
:attr:`other instance methods <method.__self__>`.)
790816

791817

792818
Classes
@@ -901,8 +927,9 @@ https://www.python.org/download/releases/2.3/mro/.
901927

902928
When a class attribute reference (for class :class:`!C`, say) would yield a
903929
class method object, it is transformed into an instance method object whose
904-
:attr:`__self__` attribute is :class:`!C`. When it would yield a static
905-
method object, it is transformed into the object wrapped by the static method
930+
:attr:`~method.__self__` attribute is :class:`!C`.
931+
When it would yield a :class:`staticmethod` object,
932+
it is transformed into the object wrapped by the static method
906933
object. See section :ref:`descriptors` for another way in which attributes
907934
retrieved from a class may differ from those actually contained in its
908935
:attr:`~object.__dict__`.
@@ -970,7 +997,7 @@ in which attribute references are searched. When an attribute is not found
970997
there, and the instance's class has an attribute by that name, the search
971998
continues with the class attributes. If a class attribute is found that is a
972999
user-defined function object, it is transformed into an instance method
973-
object whose :attr:`__self__` attribute is the instance. Static method and
1000+
object whose :attr:`~method.__self__` attribute is the instance. Static method and
9741001
class method objects are also transformed; see above under "Classes". See
9751002
section :ref:`descriptors` for another way in which attributes of a class
9761003
retrieved via its instances may differ from the objects actually stored in

_sources/tutorial/classes.rst.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ data from a string buffer instead, and pass it as an argument.
769769
or arithmetic operators, and assigning such a "pseudo-file" to sys.stdin will
770770
not cause the interpreter to read further input from it.)
771771
772-
Instance method objects have attributes, too: ``m.__self__`` is the instance
773-
object with the method :meth:`!m`, and ``m.__func__`` is the function object
772+
:ref:`Instance method objects <instance-methods>` have attributes, too:
773+
:attr:`m.__self__ <method.__self__>` is the instance
774+
object with the method :meth:`!m`, and :attr:`m.__func__ <method.__func__>` is
775+
the :ref:`function object <user-defined-funcs>`
774776
corresponding to the method.
775777

776778

_sources/whatsnew/2.6.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,8 @@ Some smaller changes made to the core Python language are:
16781678

16791679
* Instance method objects have new attributes for the object and function
16801680
comprising the method; the new synonym for :attr:`!im_self` is
1681-
:ref:`__self__ <instance-methods>`, and :attr:`!im_func` is also available as
1682-
:ref:`__func__ <instance-methods>`.
1681+
:attr:`~method.__self__`, and :attr:`!im_func` is also available as
1682+
:attr:`~method.__func__`.
16831683
The old names are still supported in Python 2.6, but are gone in 3.0.
16841684

16851685
* An obscure change: when you use the :func:`locals` function inside a

_sources/whatsnew/2.7.rst.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,10 @@ Some smaller changes made to the core Python language are:
858858

859859
.. XXX bytearray doesn't seem to be documented
860860
861-
* When using ``@classmethod`` and ``@staticmethod`` to wrap
861+
* When using :class:`@classmethod <classmethod>` and
862+
:class:`@staticmethod <staticmethod>` to wrap
862863
methods as class or static methods, the wrapper object now
863-
exposes the wrapped function as their :ref:`__func__ <instance-methods>`
864+
exposes the wrapped function as their :attr:`~method.__func__`
864865
attribute.
865866
(Contributed by Amaury Forgeot d'Arc, after a suggestion by
866867
George Sakkis; :issue:`5982`.)

about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ <h3>瀏覽</h3>
308308
<br />
309309
<br />
310310

311-
最後更新於 Dec 08, 2023 (06:14 UTC)。
311+
最後更新於 Dec 08, 2023 (16:59 UTC)。
312312
<a href="/bugs.html">Found a bug</a>?
313313
<br />
314314

0 commit comments

Comments
 (0)