@@ -88,7 +88,7 @@ Some objects contain references to "external" resources such as open files or
8888windows. It is understood that these resources are freed when the object is
8989garbage-collected, but since garbage collection is not guaranteed to happen,
9090such objects also provide an explicit way to release the external resource,
91- usually a :meth: `close ` method. Programs are strongly recommended to explicitly
91+ usually a :meth: `! close ` method. Programs are strongly recommended to explicitly
9292close such objects. The ':keyword: `try `...\ :keyword: `finally `' statement
9393and the ':keyword: `with `' statement provide convenient ways to do this.
9494
@@ -681,8 +681,8 @@ underlying the class method.
681681When an instance method object is called, the underlying function
682682(:attr: `__func__ `) is called, inserting the class instance
683683(:attr: `__self__ `) in front of the argument list. For instance, when
684- :class: `C ` is a class which contains a definition for a function
685- :meth: `f `, and ``x `` is an instance of :class: `C `, calling ``x.f(1) `` is
684+ :class: `! C ` is a class which contains a definition for a function
685+ :meth: `! f `, and ``x `` is an instance of :class: `! C `, calling ``x.f(1) `` is
686686equivalent to calling ``C.f(x, 1) ``.
687687
688688When an instance method object is derived from a class method object, the
@@ -795,7 +795,7 @@ Classes
795795Classes are callable. These objects normally act as factories for new
796796instances of themselves, but variations are possible for class types that
797797override :meth: `~object.__new__ `. The arguments of the call are passed to
798- :meth: `__new__ ` and, in the typical case, to :meth: `~object.__init__ ` to
798+ :meth: `! __new__ ` and, in the typical case, to :meth: `~object.__init__ ` to
799799initialize the new instance.
800800
801801
@@ -899,9 +899,9 @@ https://www.python.org/download/releases/2.3/mro/.
899899 pair: object; dictionary
900900 pair: class; attribute
901901
902- When a class attribute reference (for class :class: `C `, say) would yield a
902+ When a class attribute reference (for class :class: `! C `, say) would yield a
903903class method object, it is transformed into an instance method object whose
904- :attr: `__self__ ` attribute is :class: `C `. When it would yield a static
904+ :attr: `__self__ ` attribute is :class: `! C `. When it would yield a static
905905method object, it is transformed into the object wrapped by the static method
906906object. See section :ref: `descriptors ` for another way in which attributes
907907retrieved from a class may differ from those actually contained in its
@@ -1903,13 +1903,17 @@ class' :attr:`~object.__dict__`.
19031903
19041904 Called to delete the attribute on an instance *instance * of the owner class.
19051905
1906+ Instances of descriptors may also have the :attr: `!__objclass__ ` attribute
1907+ present:
19061908
1907- The attribute :attr: `__objclass__ ` is interpreted by the :mod: `inspect ` module
1908- as specifying the class where this object was defined (setting this
1909- appropriately can assist in runtime introspection of dynamic class attributes).
1910- For callables, it may indicate that an instance of the given type (or a
1911- subclass) is expected or required as the first positional argument (for example,
1912- CPython sets this attribute for unbound methods that are implemented in C).
1909+ .. attribute :: object.__objclass__
1910+
1911+ The attribute :attr: `!__objclass__ ` is interpreted by the :mod: `inspect ` module
1912+ as specifying the class where this object was defined (setting this
1913+ appropriately can assist in runtime introspection of dynamic class attributes).
1914+ For callables, it may indicate that an instance of the given type (or a
1915+ subclass) is expected or required as the first positional argument (for example,
1916+ CPython sets this attribute for unbound methods that are implemented in C).
19131917
19141918
19151919.. _descriptor-invocation :
@@ -1990,13 +1994,14 @@ For instance bindings, the precedence of descriptor invocation depends on
19901994which descriptor methods are defined. A descriptor can define any combination
19911995of :meth: `~object.__get__ `, :meth: `~object.__set__ ` and
19921996:meth: `~object.__delete__ `. If it does not
1993- define :meth: `__get__ `, then accessing the attribute will return the descriptor
1997+ define :meth: `! __get__ `, then accessing the attribute will return the descriptor
19941998object itself unless there is a value in the object's instance dictionary. If
1995- the descriptor defines :meth: `__set__ ` and/or :meth: `__delete__ `, it is a data
1999+ the descriptor defines :meth: `! __set__ ` and/or :meth: `! __delete__ `, it is a data
19962000descriptor; if it defines neither, it is a non-data descriptor. Normally, data
1997- descriptors define both :meth: `__get__ ` and :meth: `__set__ `, while non-data
1998- descriptors have just the :meth: `__get__ ` method. Data descriptors with
1999- :meth: `__get__ ` and :meth: `__set__ ` (and/or :meth: `__delete__ `) defined always override a redefinition in an
2001+ descriptors define both :meth: `!__get__ ` and :meth: `!__set__ `, while non-data
2002+ descriptors have just the :meth: `!__get__ ` method. Data descriptors with
2003+ :meth: `!__get__ ` and :meth: `!__set__ ` (and/or :meth: `!__delete__ `) defined
2004+ always override a redefinition in an
20002005instance dictionary. In contrast, non-data descriptors can be overridden by
20012006instances.
20022007
@@ -2573,16 +2578,17 @@ either to emulate a sequence or to emulate a mapping; the difference is that for
25732578a sequence, the allowable keys should be the integers *k * for which ``0 <= k <
25742579N `` where *N * is the length of the sequence, or :class: `slice ` objects, which define a
25752580range of items. It is also recommended that mappings provide the methods
2576- :meth: `keys `, :meth: `values `, :meth: `items `, :meth: `get `, :meth: `clear `,
2577- :meth: `setdefault `, :meth: `pop `, :meth: `popitem `, :meth: `!copy `, and
2578- :meth: `update ` behaving similar to those for Python's standard :class: `dictionary <dict> `
2581+ :meth: `! keys `, :meth: `! values `, :meth: `! items `, :meth: `! get `, :meth: `! clear `,
2582+ :meth: `! setdefault `, :meth: `! pop `, :meth: `! popitem `, :meth: `!copy `, and
2583+ :meth: `! update ` behaving similar to those for Python's standard :class: `dictionary <dict> `
25792584objects. The :mod: `collections.abc ` module provides a
25802585:class: `~collections.abc.MutableMapping `
25812586:term: `abstract base class ` to help create those methods from a base set of
2582- :meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `, :meth: `~object.__delitem__ `, and :meth: `keys `.
2583- Mutable sequences should provide methods :meth: `append `, :meth: `count `,
2584- :meth: `index `, :meth: `extend `, :meth: `insert `, :meth: `pop `, :meth: `remove `,
2585- :meth: `reverse ` and :meth: `sort `, like Python standard :class: `list `
2587+ :meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `,
2588+ :meth: `~object.__delitem__ `, and :meth: `!keys `.
2589+ Mutable sequences should provide methods :meth: `!append `, :meth: `!count `,
2590+ :meth: `!index `, :meth: `!extend `, :meth: `!insert `, :meth: `!pop `, :meth: `!remove `,
2591+ :meth: `!reverse ` and :meth: `!sort `, like Python standard :class: `list `
25862592objects. Finally,
25872593sequence types should implement addition (meaning concatenation) and
25882594multiplication (meaning repetition) by defining the methods
@@ -2595,7 +2601,7 @@ operator; for
25952601mappings, ``in `` should search the mapping's keys; for sequences, it should
25962602search through the values. It is further recommended that both mappings and
25972603sequences implement the :meth: `~object.__iter__ ` method to allow efficient iteration
2598- through the container; for mappings, :meth: `__iter__ ` should iterate
2604+ through the container; for mappings, :meth: `! __iter__ ` should iterate
25992605through the object's keys; for sequences, it should iterate through the values.
26002606
26012607.. method :: object.__len__(self)
@@ -3174,7 +3180,7 @@ generators, coroutines do not directly support iteration.
31743180 to the :meth: `~generator.send ` method of the iterator that caused
31753181 the coroutine to suspend. The result (return value,
31763182 :exc: `StopIteration `, or other exception) is the same as when
3177- iterating over the :meth: `__await__ ` return value, described above.
3183+ iterating over the :meth: `! __await__ ` return value, described above.
31783184
31793185.. method :: coroutine.throw(value)
31803186 coroutine.throw(type[, value[, traceback]])
0 commit comments