+ 1

Magic __add__ question

Talking about how the __add__ example I find that negative values won’t work. Why is that?

21st Jun 2019, 3:49 PM
James
James - avatar
2 Respostas
+ 1
Actually it does work with negatives and negative results I had erased the closing ) on one of the variables when I substituted negatives. Shoulda took a 2nd look.
21st Jun 2019, 5:58 PM
James
James - avatar
0
I have a hypothesis that using negative values within addition would perform subtraction and thus call the __sub__ magic method instead.
21st Jun 2019, 4:47 PM
Seb TheS
Seb TheS - avatar