subclassing 'list'

akineko akineko at gmail.com
Tue Jan 6 15:34:48 EST 2009


Hello everyone,

I'm creating a class which is subclassed from list (Bulit-in type).

It works great.
However, I'm having a hard time finding a way to set a new value to
the object (within the class).
There are methods that alter a part of the object (ex. __setitem__()).
But I couldn't find any method that can replace the value of the
object.
I wanted to do something like the following:

class Mylist(list):

    def arrange(self):
        new_value = ....
        list.self.__assign__.(self, new_value)

I serached the newsgroup and found that assignment operator ('=')
cannot be overridden because it is not an operator. But it shouldn't
stop Python to provide a way to re-assign the value internally.

Any suggestions will be highly appreciated.

Best regards,
Aki-



More information about the Python-list mailing list