## velocity
def get_velocity(self):
return ( (self.dx, self.dy) )
def set_velocity (self, new_velocity):
self.dx, self.dy = new_velocity
velocity = property(get_velocity, set_velocity)
The above is from the source code of a module I am using.
So to get the velocity values individually (dx separately, and dy separately), would this work?
self.get_velocity() = lala
lala[1] = dx value and lala[2] = dy value
Is this correct?
No, because when you want to assign the return value of a function to a variable, you have to have the variable on the left and the function on the right:
With that one change, it should work. But note that you can do the same thing with less typing like so: