@@ -57,7 +57,8 @@ are always available. They are listed here in alphabetical order.
5757.. function :: abs(x)
5858
5959 Return the absolute value of a number. The argument may be an
60- integer, a floating point number, or an object implementing :meth: `__abs__ `.
60+ integer, a floating point number, or an object implementing
61+ :meth: `~object.__abs__ `.
6162 If the argument is a complex number, its magnitude is returned.
6263
6364
@@ -235,7 +236,7 @@ are always available. They are listed here in alphabetical order.
235236 :const: `False ` if not. If this returns ``True ``, it is still possible that a
236237 call fails, but if it is ``False ``, calling *object * will never succeed.
237238 Note that classes are callable (calling a class returns a new instance);
238- instances are callable if their class has a :meth: `__call__ ` method.
239+ instances are callable if their class has a :meth: `~object. __call__ ` method.
239240
240241 .. versionadded :: 3.2
241242 This function was first removed in Python 3.0 and then brought back
@@ -432,15 +433,18 @@ are always available. They are listed here in alphabetical order.
432433 Without arguments, return the list of names in the current local scope. With an
433434 argument, attempt to return a list of valid attributes for that object.
434435
435- If the object has a method named :meth: `__dir__ `, this method will be called and
436+ If the object has a method named :meth: `~object.__dir__ `,
437+ this method will be called and
436438 must return the list of attributes. This allows objects that implement a custom
437- :func: `__getattr__ ` or :func: `__getattribute__ ` function to customize the way
439+ :func: `~object.__getattr__ ` or :func: `~object.__getattribute__ ` function
440+ to customize the way
438441 :func: `dir ` reports their attributes.
439442
440- If the object does not provide :meth: `__dir__ `, the function tries its best to
441- gather information from the object's :attr: `~object.__dict__ ` attribute, if defined, and
443+ If the object does not provide :meth: `~object.__dir__ `,
444+ the function tries its best to gather information from the object's
445+ :attr: `~object.__dict__ ` attribute, if defined, and
442446 from its type object. The resulting list is not necessarily complete and may
443- be inaccurate when the object has a custom :func: `__getattr__ `.
447+ be inaccurate when the object has a custom :func: `~object. __getattr__ `.
444448
445449 The default :func: `dir ` mechanism behaves differently with different types of
446450 objects, as it attempts to produce the most relevant, rather than complete,
@@ -664,7 +668,7 @@ are always available. They are listed here in alphabetical order.
664668 sign: "+" | "-"
665669 infinity: "Infinity" | "inf"
666670 nan: "nan"
667- digitpart: `digit ` (["_"] `digit `)*
671+ digitpart: `! digit ` (["_"] `! digit `)*
668672 number: [`digitpart `] "." `digitpart ` | `digitpart ` ["."]
669673 exponent: ("e" | "E") ["+" | "-"] `digitpart `
670674 floatnumber: number [`exponent `]
@@ -727,8 +731,8 @@ are always available. They are listed here in alphabetical order.
727731
728732 A call to ``format(value, format_spec) `` is translated to
729733 ``type(value).__format__(value, format_spec) `` which bypasses the instance
730- dictionary when searching for the value's :meth: `__format__ ` method. A
731- :exc: `TypeError ` exception is raised if the method search reaches
734+ dictionary when searching for the value's :meth: `~object. __format__ ` method.
735+ A :exc: `TypeError ` exception is raised if the method search reaches
732736 :mod: `object ` and the *format_spec * is non-empty, or if either the
733737 *format_spec * or the return value are not strings.
734738
@@ -792,9 +796,9 @@ are always available. They are listed here in alphabetical order.
792796
793797 .. note ::
794798
795- For objects with custom :meth: `__hash__ ` methods, note that :func: `hash `
799+ For objects with custom :meth: `~object.__hash__ ` methods,
800+ note that :func: `hash `
796801 truncates the return value based on the bit width of the host machine.
797- See :meth: `__hash__ <object.__hash__> ` for details.
798802
799803.. function :: help()
800804 help(request)
@@ -982,7 +986,8 @@ are always available. They are listed here in alphabetical order.
982986 Return an :term: `iterator ` object. The first argument is interpreted very
983987 differently depending on the presence of the second argument. Without a
984988 second argument, *object * must be a collection object which supports the
985- :term: `iterable ` protocol (the :meth: `__iter__ ` method), or it must support
989+ :term: `iterable ` protocol (the :meth: `~object.__iter__ ` method),
990+ or it must support
986991 the sequence protocol (the :meth: `~object.__getitem__ ` method with integer arguments
987992 starting at ``0 ``). If it does not support either of those protocols,
988993 :exc: `TypeError ` is raised. If the second argument, *sentinel *, is given,
@@ -1500,38 +1505,44 @@ are always available. They are listed here in alphabetical order.
15001505 """Get the current voltage."""
15011506 return self._voltage
15021507
1503- The ``@property `` decorator turns the :meth: `voltage ` method into a "getter"
1508+ The ``@property `` decorator turns the :meth: `! voltage ` method into a "getter"
15041509 for a read-only attribute with the same name, and it sets the docstring for
15051510 *voltage * to "Get the current voltage."
15061511
1507- A property object has :attr: `~property.getter `, :attr: `~property.setter `,
1508- and :attr: `~property.deleter ` methods usable as decorators that create a
1509- copy of the property with the corresponding accessor function set to the
1510- decorated function. This is best explained with an example::
1512+ .. decorator :: property.getter
1513+ .. decorator :: property.setter
1514+ .. decorator :: property.deleter
15111515
1512- class C:
1513- def __init__(self):
1514- self._x = None
1516+ A property object has ``getter ``, ``setter ``,
1517+ and ``deleter `` methods usable as decorators that create a
1518+ copy of the property with the corresponding accessor function set to the
1519+ decorated function. This is best explained with an example:
15151520
1516- @property
1517- def x(self):
1518- """I'm the 'x' property."""
1519- return self._x
1521+ .. testcode ::
15201522
1521- @x.setter
1522- def x (self, value ):
1523- self._x = value
1523+ class C:
1524+ def __init__ (self):
1525+ self._x = None
15241526
1525- @x.deleter
1526- def x(self):
1527- del self._x
1527+ @property
1528+ def x(self):
1529+ """I'm the 'x' property."""
1530+ return self._x
15281531
1529- This code is exactly equivalent to the first example. Be sure to give the
1530- additional functions the same name as the original property (`` x `` in this
1531- case.)
1532+ @x.setter
1533+ def x(self, value):
1534+ self._x = value
15321535
1533- The returned property object also has the attributes ``fget ``, ``fset ``, and
1534- ``fdel `` corresponding to the constructor arguments.
1536+ @x.deleter
1537+ def x(self):
1538+ del self._x
1539+
1540+ This code is exactly equivalent to the first example. Be sure to give the
1541+ additional functions the same name as the original property (``x `` in this
1542+ case.)
1543+
1544+ The returned property object also has the attributes ``fget ``, ``fset ``, and
1545+ ``fdel `` corresponding to the constructor arguments.
15351546
15361547 .. versionchanged :: 3.5
15371548 The docstrings of property objects are now writeable.
@@ -1554,17 +1565,18 @@ are always available. They are listed here in alphabetical order.
15541565 representation is a string enclosed in angle brackets that contains the name
15551566 of the type of the object together with additional information often
15561567 including the name and address of the object. A class can control what this
1557- function returns for its instances by defining a :meth: `__repr__ ` method.
1568+ function returns for its instances
1569+ by defining a :meth: `~object.__repr__ ` method.
15581570 If :func: `sys.displayhook ` is not accessible, this function will raise
15591571 :exc: `RuntimeError `.
15601572
15611573
15621574.. function :: reversed(seq)
15631575
15641576 Return a reverse :term: `iterator `. *seq * must be an object which has
1565- a :meth: `__reversed__ ` method or supports the sequence protocol (the
1566- :meth: `__len__ ` method and the :meth: `~object.__getitem__ ` method with integer
1567- arguments starting at ``0 ``).
1577+ a :meth: `~object. __reversed__ ` method or supports the sequence protocol (the
1578+ :meth: `~object. __len__ ` method and the :meth: `~object.__getitem__ ` method
1579+ with integer arguments starting at ``0 ``).
15681580
15691581
15701582.. function :: round(number, ndigits=None)
@@ -1635,13 +1647,21 @@ are always available. They are listed here in alphabetical order.
16351647
16361648 Return a :term: `slice ` object representing the set of indices specified by
16371649 ``range(start, stop, step) ``. The *start * and *step * arguments default to
1638- ``None ``. Slice objects have read-only data attributes :attr: `~slice.start `,
1639- :attr: `~slice.stop `, and :attr: `~slice.step ` which merely return the argument
1640- values (or their default). They have no other explicit functionality;
1641- however, they are used by NumPy and other third-party packages.
1650+ ``None ``.
1651+
1652+ .. attribute :: slice.start
1653+ .. attribute :: slice.stop
1654+ .. attribute :: slice.step
1655+
1656+ Slice objects have read-only data attributes :attr: `!start `,
1657+ :attr: `!stop `, and :attr: `!step ` which merely return the argument
1658+ values (or their default). They have no other explicit functionality;
1659+ however, they are used by NumPy and other third-party packages.
1660+
16421661 Slice objects are also generated when extended indexing syntax is used. For
16431662 example: ``a[start:stop:step] `` or ``a[start:stop, i] ``. See
1644- :func: `itertools.islice ` for an alternate version that returns an iterator.
1663+ :func: `itertools.islice ` for an alternate version that returns an
1664+ :term: `iterator `.
16451665
16461666 .. versionchanged :: 3.12
16471667 Slice objects are now :term: `hashable ` (provided :attr: `~slice.start `,
@@ -1808,7 +1828,8 @@ are always available. They are listed here in alphabetical order.
18081828
18091829 Note that :func: `super ` is implemented as part of the binding process for
18101830 explicit dotted attribute lookups such as ``super().__getitem__(name) ``.
1811- It does so by implementing its own :meth: `__getattribute__ ` method for searching
1831+ It does so by implementing its own :meth: `~object.__getattribute__ ` method
1832+ for searching
18121833 classes in a predictable order that supports cooperative multiple inheritance.
18131834 Accordingly, :func: `super ` is undefined for implicit lookups using statements or
18141835 operators such as ``super()[name] ``.
0 commit comments