I have a class Vec3D (see http://pastebin.com/9Y7YbCZq)
Currently, I allow Vec3D(1,0,0) + 1.2 but I'm wondering how I should proceed to overload the + operator in such a way that I get the following output:
>>> 3.3 + Vec3D(1,0,0)
[4.3, 3.3 , 3.3]
Code is not required, but just a hint in which direction I should look. Something general will be more useful than a specific implementation as I need to implement the same thing for multiplication, subtraction etc.
__radd__ = __add__
. This works because radd swaps the argument order for you.