Kaydet (Commit) 548db58e authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Use operator.index() instead of n.__index__().

üst 655d583a
......@@ -96,11 +96,8 @@ class Fraction(Rational):
if denominator == 0:
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
try:
numerator = numerator.__index__()
denominator = denominator.__index__()
except AttributeError:
raise TypeError('Numerator and denominator must support __index__.')
numerator = operator.index(numerator)
denominator = operator.index(denominator)
g = gcd(numerator, denominator)
self._numerator = numerator // g
self._denominator = denominator // g
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment