8
8
9
9
--------------
10
10
11
- The:mod: `numbers ` module (:pep: `3141 `) defines a hierarchy of numeric
11
+ The:mod: `! numbers ` module (:pep: `3141 `) defines a hierarchy of numeric
12
12
:term: `abstract base classes <abstract base class> ` which progressively define
13
13
more operations. None of the types defined in this module are intended to be instantiated.
14
14
@@ -45,7 +45,7 @@ The numeric tower
45
45
46
46
..class ::Real
47
47
48
- To:class: `Complex `,:class: `Real ` adds the operations that work on real
48
+ To:class: `Complex `,:class: `! Real ` adds the operations that work on real
49
49
numbers.
50
50
51
51
In short, those are: a conversion to:class: `float `,:func: `math.trunc `,
@@ -126,7 +126,8 @@ We want to implement the arithmetic operations so that mixed-mode
126
126
operations either call an implementation whose author knew about the
127
127
types of both arguments, or convert both to the nearest built in type
128
128
and do the operation there. For subtypes of:class: `Integral `, this
129
- means that:meth: `__add__ ` and:meth: `__radd__ ` should be defined as::
129
+ means that:meth: `~object.__add__ ` and:meth: `~object.__radd__ ` should be
130
+ defined as::
130
131
131
132
class MyIntegral(Integral):
132
133
@@ -160,15 +161,15 @@ refer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as
160
161
of:class: `Complex ` (``a : A <: Complex ``), and ``b : B <:
161
162
Complex ``. I'll consider ``a + b ``:
162
163
163
- 1. If ``A `` defines an:meth: `__add__ ` which accepts ``b ``, all is
164
+ 1. If ``A `` defines an:meth: `~object. __add__ ` which accepts ``b ``, all is
164
165
well.
165
166
2. If ``A `` falls back to the boilerplate code, and it were to
166
- return a value from:meth: `__add__ `, we'd miss the possibility
167
- that ``B `` defines a more intelligent:meth: `__radd__ `, so the
167
+ return a value from:meth: `~object. __add__ `, we'd miss the possibility
168
+ that ``B `` defines a more intelligent:meth: `~object. __radd__ `, so the
168
169
boilerplate should return:const: `NotImplemented ` from
169
- :meth: `__add__ `. (Or ``A `` may not implement:meth: `__add__ ` at
170
+ :meth: `! __add__ `. (Or ``A `` may not implement:meth: `! __add__ ` at
170
171
all.)
171
- 3. Then ``B ``'s:meth: `__radd__ ` gets a chance. If it accepts
172
+ 3. Then ``B ``'s:meth: `~object. __radd__ ` gets a chance. If it accepts
172
173
``a ``, all is well.
173
174
4. If it falls back to the boilerplate, there are no more possible
174
175
methods to try, so this is where the default implementation
@@ -180,7 +181,7 @@ Complex``. I'll consider ``a + b``:
180
181
181
182
If ``A <: Complex `` and ``B <: Real `` without sharing any other knowledge,
182
183
then the appropriate shared operation is the one involving the built
183
- in:class: `complex `, and both:meth: `__radd__ ` s land there, so ``a+b
184
+ in:class: `complex `, and both:meth: `~object. __radd__ ` s land there, so ``a+b
184
185
== b+a ``.
185
186
186
187
Because most of the operations on any given type will be very similar,