what does it mean | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what does it mean

However, if x hasn't implemented __add__, and x and y are of different types, then y.__radd__(x) is called. #what does it mean, do we need to follow a kind of order while coding?

22nd Jun 2020, 9:35 AM
Zhengrong Yan
Zhengrong Yan - avatar
1 Answer
+ 3
Think about points on a graph. The whole way a point is set up looks like a tuple with two values (x and y). If we were to make a Point class, then it would be instansiated with an x and y value, for example Point(3, 6). Problem is, you cant really add tuples together. So you can "overload" how the Point class reacts to a plus sign or multiplication sign or whatever with magic methods.
22nd Jun 2020, 10:05 AM
Slick
Slick - avatar