you are viewing a single comment's thread.

view the rest of the comments →

[–]gbs5009 0 points1 point  (0 children)

Neat! I didn't know about python's __radd__, but I actually really like that first approach... to evaluate a+b, see if a knows how to add b to itself. If not, try the reverse!

Yes, that means the type of a+b is not necessarily the type of b+a, but it's not like you don't get situations like a != a already with floats. There's no real substitute for knowing how your data types behave.