MCPcopy Index your code
hub / github.com/python/cpython / __truediv__

Method __truediv__

Lib/test/test_binop.py:128–136  ·  view source on GitHub ↗

Divide two Rats, or a Rat and a number.

(self, other)

Source from the content-addressed store, hash-verified

126 __rmul__ = __mul__
127
128 def __truediv__(self, other):
129 """Divide two Rats, or a Rat and a number."""
130 if isRat(other):
131 return Rat(self.__num*other.__den, self.__den*other.__num)
132 if isint(other):
133 return Rat(self.__num, self.__den*other)
134 if isnum(other):
135 return float(self) / other
136 return NotImplemented
137
138 def __rtruediv__(self, other):
139 """Divide two Rats, or a Rat and a number (reversed args)."""

Callers 2

test_truedivMethod · 0.45
test_floatasratioMethod · 0.45

Calls 4

isRatFunction · 0.85
isintFunction · 0.85
isnumFunction · 0.85
RatClass · 0.70

Tested by

no test coverage detected