Append and delete elements from a list using property
<p>In my base class is <em>_mylist</em> defined as a <em>list</em></p>

<pre><code>class Foo(object):

    def __init__(self):
        self._mylist = list()

    @property
    def mylist(self):
        return self._mylist

    @mylist.setter
    def mylist(self, value):
        self._mylist = value
</code></pre>

<p>In my derived class Boo </p>

<pre><code>class Boo(Foo)
    def __init__(self):
    """   """

    def add_element(self,value):
        Foo.mylist.appened(value)
</code></pre>

<p>I would like to add and delete elements to <em>mylist</em> from <em>Boo</em>.
I tried the following:</p>

<pre><code>boo = Boo()
boo.add\_element(5)
</code></pre>

<p>Following exception came up:</p>

<pre><code>AttributeError: 'property' object has no attribute 'append'
</code></pre>

<p>At present I modified the setter property of <em>mylist</em> to look like:</p>

<pre><code>    @mylist.setter
    def mylist(self, value):
        self._mylist.append( value )
</code></pre>

<p>This allow me to add elements to my <em>mylist</em>, but i don't know how to delete elements from it.</p>

<p>Is there a better way of modifing a list in based class from the derived class?</p>

<p>Try something like this:</p>

<pre><code>@property
def del_element(self, value):
    self._mylist.remove(value)

@property
def add_element(self,value):
    self._mylist.append(value)
</code></pre>

python python-3.x