When using Python properties (setters and getters), usually following is used:
class MyClass(object):
...
@property
def my_attr(self):
...
@my_attr.setter
def my_attr(self, value):
...
However, is there any similar approach for appending / removing arrays? For example, in a bi-directional relationship between two objects, when removing object A, it would be nice to dereference the relationship to A in object B. I know that SQLAlchemy has implemeneted a similar function.
I also know that I can implement methods like
def add_element_to_some_array(element):
some_array.append(element)
element.some_parent(self)
but I would prefer to do it like "properties" in Python.. do you know some way?