Skip to content

Commit 91598f9

Browse files
committed
1 parent 98d09e7 commit 91598f9

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

Lib/numbers.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@
55
66
TODO: Fill out more detailed documentation on the operators."""
77

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+
833
from abc import ABCMeta, abstractmethod
934

1035
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
@@ -118,7 +143,7 @@ def __rtruediv__(self, other):
118143

119144
@abstractmethod
120145
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."""
122147
raise NotImplementedError
123148

124149
@abstractmethod
@@ -167,7 +192,7 @@ def __trunc__(self):
167192
"""trunc(self): Truncates self to an Integral.
168193
169194
Returns an Integral i such that:
170-
* i>0 iff self>0;
195+
* i > 0 iff self > 0;
171196
* abs(i) <= abs(self);
172197
* for any Integral j satisfying the first two conditions,
173198
abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
@@ -203,7 +228,7 @@ def __divmod__(self, other):
203228
return (self // other, self % other)
204229

205230
def __rdivmod__(self, other):
206-
"""divmod(other, self): The pair (self // other, self % other).
231+
"""divmod(other, self): The pair (other // self, other % self).
207232
208233
Sometimes this can be computed faster than the pair of
209234
operations.

0 commit comments

Comments
 (0)