I have a class Particle which has some parameters and attributes, as you can see below. But, when it does get to the function setter for position, and it executes t
It looks like you're trying to use position
as the name of both the property and the ordinary attribute backing it. For example,
@position.setter
def position(self, newPosition):
self.position = newPosition.copy()
# ^^^^^^^^^^^^^^^
This attempt to set self.position
will use the setter you're defining! Similarly,
@property
def position(self):
return self.position
This getter just calls itself!
Trying to use self.position
inside the position
property definition won't bypass the property. If you want a "regular" attribute backing the property, call it something else, like self._position
or something.