Answer the question
In order to leave comments, you need to log in
When does __sub__() fire?
There is this code:
class Number:
def __init__(self, start):
self.data = start
def __sub__(self, other):
return Number(self.data - other)
X = Number(5)
Y = X - 2
print(Y.data)
Y = X - 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question