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

Method __add__

Lib/test/test_binop.py:81–90  ·  view source on GitHub ↗

Add two Rats, or a Rat and a number.

(self, other)

Source from the content-addressed store, hash-verified

79 raise ValueError("can't convert %s to int" % repr(self))
80
81 def __add__(self, other):
82 """Add two Rats, or a Rat and a number."""
83 if isint(other):
84 other = Rat(other)
85 if isRat(other):
86 return Rat(self.__num*other.__den + other.__num*self.__den,
87 self.__den*other.__den)
88 if isnum(other):
89 return float(self) + other
90 return NotImplemented
91
92 __radd__ = __add__
93

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