I found out yesterday that it is possible to override operators in python, so after a bit of googling i found out how, but i could not find any way of overloading the "=" sign. There is __set__() but as i understand it, it overloads the sign for attributes in the object, and not for the object itself.
What i want to accomplish is this:
F = Foo(1)
G = Foo(2)
F = G #overloaded =
So is there a way of overloading "=" for an object in python? (and what is that function called)
=(assignment) not==(equality comparison)?propertywith a setter could do that. But it only works on object attributes not on "free" variables. There are other options you might want to consider:setattr(), a dictionary, the__dict__attribute…