diff options
author | Raymond Hettinger <python@rcn.com> | 2008-01-31 22:07:16 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-01-31 22:07:16 (GMT) |
commit | 2df20a3e0816537db68618cef0603e89773beac4 (patch) | |
tree | 0867b34c634efcf5b700f4448732b934eb121f17 | |
parent | 38db364076e593a5111ce948b6379f15819fcaf8 (diff) | |
download | cpython-2df20a3e0816537db68618cef0603e89773beac4.zip cpython-2df20a3e0816537db68618cef0603e89773beac4.tar.gz cpython-2df20a3e0816537db68618cef0603e89773beac4.tar.bz2 |
Minor wordsmithing on docstring
-rwxr-xr-x | Lib/rational.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/rational.py b/Lib/rational.py index b922fbf..2222045 100755 --- a/Lib/rational.py +++ b/Lib/rational.py @@ -193,20 +193,20 @@ class Rational(RationalAbc): Rational, that means that we define __add__ and __radd__ as: def __add__(self, other): + # Both types have numerators/denominator attributes, + # so do the operation directly if isinstance(other, (int, long, Rational)): - # Do the real operation. return Rational(self.numerator * other.denominator + other.numerator * self.denominator, self.denominator * other.denominator) - # float and complex don't follow this protocol, and - # Rational knows about them, so special case them. + # float and complex don't have those operations, but we + # know about those types, so special case them. elif isinstance(other, float): return float(self) + other elif isinstance(other, complex): return complex(self) + other - else: - # Let the other type take over. - return NotImplemented + # Let the other type take over. + return NotImplemented def __radd__(self, other): # radd handles more types than add because there's @@ -219,8 +219,7 @@ class Rational(RationalAbc): return float(other) + float(self) elif isinstance(other, Complex): return complex(other) + complex(self) - else: - return NotImplemented + return NotImplemented There are 5 different cases for a mixed-type addition on |