New init for fraction
This commit is contained in:
parent
e34215a9a9
commit
f5c64ce9e4
@ -22,13 +22,14 @@ class Fraction(Explicable):
|
|||||||
:param denom: the denominator
|
:param denom: the denominator
|
||||||
|
|
||||||
"""
|
"""
|
||||||
super(Fraction, self).__init__()
|
|
||||||
self._num = num
|
self._num = num
|
||||||
if denom == 0:
|
if denom == 0:
|
||||||
raise ZeroDivisionError("Can't create Fraction: division by zero")
|
raise ZeroDivisionError("Can't create Fraction: division by zero")
|
||||||
self._denom = denom
|
self._denom = denom
|
||||||
|
|
||||||
self.isNumber = 1
|
self.isNumber = 1
|
||||||
|
pstf_tokens = self.compute_postfix_tokens()
|
||||||
|
super(Fraction, self).__init__(pstf_tokens)
|
||||||
|
|
||||||
def simplify(self):
|
def simplify(self):
|
||||||
"""Simplify the fraction
|
"""Simplify the fraction
|
||||||
@ -87,8 +88,7 @@ class Fraction(Explicable):
|
|||||||
else:
|
else:
|
||||||
return copy(self)
|
return copy(self)
|
||||||
|
|
||||||
@property
|
def compute_postfix_tokens(self):
|
||||||
def postfix_tokens(self):
|
|
||||||
"""Postfix form of the fraction
|
"""Postfix form of the fraction
|
||||||
|
|
||||||
>>> f = Fraction(3, 5)
|
>>> f = Fraction(3, 5)
|
||||||
|
Loading…
Reference in New Issue
Block a user