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

Method __sub__

Lib/test/test_binop.py:94–103  ·  view source on GitHub ↗

Subtract two Rats, or a Rat and a number.

(self, other)

Source from the content-addressed store, hash-verified

92 __radd__ = __add__
93
94 def __sub__(self, other):
95 """Subtract two Rats, or a Rat and a number."""
96 if isint(other):
97 other = Rat(other)
98 if isRat(other):
99 return Rat(self.__num*other.__den - other.__num*self.__den,
100 self.__den*other.__den)
101 if isnum(other):
102 return float(self) - other
103 return NotImplemented
104
105 def __rsub__(self, other):
106 """Subtract two Rats, or a Rat and a number (reversed args)."""

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected