+ 9

(SOLVED) Python magic "r..." methods

What is the purpose of "r" magic methods, like __radd__? SoloLearn didn't explained that well.

8th Jul 2021, 12:09 PM
🇺🇦 GUMBALL 🇺🇦 [Dead account]
2 Respuestas
+ 3
when doing a+b It tries to do a.__add__(b) If it is not defined then it tries b.__radd__(a) It's called __radd__ becouse it's the object on the right side of the operand to call it
8th Jul 2021, 12:35 PM
Angelo
Angelo - avatar
+ 7
Angelo Thank you for answer! 😊
8th Jul 2021, 1:04 PM
🇺🇦 GUMBALL 🇺🇦 [Dead account]