|
5 | 5 |
|
6 | 6 | TODO: Fill out more detailed documentation on the operators."""
|
7 | 7 |
|
| 8 | +############ Maintenance notes ######################################### |
| 9 | +# |
| 10 | +# ABCs are different from other standard library modules in that they |
| 11 | +# specify compliance tests. In general, once an ABC has been published, |
| 12 | +# new methods (either abstract or concrete) cannot be added. |
| 13 | +# |
| 14 | +# Though classes that inherit from an ABC would automatically receive a |
| 15 | +# new mixin method, registered classes would become non-compliant and |
| 16 | +# violate the contract promised by ``isinstance(someobj, SomeABC)``. |
| 17 | +# |
| 18 | +# Though irritating, the correct procedure for adding new abstract or |
| 19 | +# mixin methods is to create a new ABC as a subclass of the previous |
| 20 | +# ABC. |
| 21 | +# |
| 22 | +# Because they are so hard to change, new ABCs should have their APIs |
| 23 | +# carefully thought through prior to publication. |
| 24 | +# |
| 25 | +# Since ABCMeta only checks for the presence of methods, it is possible |
| 26 | +# to alter the signature of a method by adding optional arguments |
| 27 | +# or changing parameter names. This is still a bit dubious but at |
| 28 | +# least it won't cause isinstance() to return an incorrect result. |
| 29 | +# |
| 30 | +# |
| 31 | +####################################################################### |
| 32 | + |
8 | 33 | from abc import ABCMeta, abstractmethod
|
9 | 34 |
|
10 | 35 | __all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
|
@@ -118,7 +143,7 @@ def __rtruediv__(self, other):
|
118 | 143 |
|
119 | 144 | @abstractmethod
|
120 | 145 | def __pow__(self, exponent):
|
121 |
| - """self**exponent; should promote to float or complex when necessary.""" |
| 146 | + """self ** exponent; should promote to float or complex when necessary.""" |
122 | 147 | raise NotImplementedError
|
123 | 148 |
|
124 | 149 | @abstractmethod
|
@@ -167,7 +192,7 @@ def __trunc__(self):
|
167 | 192 | """trunc(self): Truncates self to an Integral.
|
168 | 193 |
|
169 | 194 | Returns an Integral i such that:
|
170 |
| - * i>0 iff self>0; |
| 195 | + * i > 0 iff self > 0; |
171 | 196 | * abs(i) <= abs(self);
|
172 | 197 | * for any Integral j satisfying the first two conditions,
|
173 | 198 | abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
|
@@ -203,7 +228,7 @@ def __divmod__(self, other):
|
203 | 228 | return (self // other, self % other)
|
204 | 229 |
|
205 | 230 | def __rdivmod__(self, other):
|
206 |
| - """divmod(other, self): The pair (self // other, self % other). |
| 231 | + """divmod(other, self): The pair (other // self, other % self). |
207 | 232 |
|
208 | 233 | Sometimes this can be computed faster than the pair of
|
209 | 234 | operations.
|
|
0 commit comments