Hi all,
I'm trying to figure out how to subclass the list built-in.
. class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
. mine = my_list((1,2,3,4))
. mine.append(42)
. mine
[1, 2, 3, 4, 42]
.
On 22 Feb 2005, [EMAIL PROTECTED] wrote:
I'm trying to figure out how to subclass the list built-in.
. class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
. mine = my_list((1,2,3,4))
.
Brian van den Broek wrote:
Hi all,
I'm trying to figure out how to subclass the list built-in.
. class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
. mine = my_list((1,2,3,4))
. mine.append(42)
. mine
[1,
Karl Pflästerer said unto the world upon 2005-02-22 07:53:
On 22 Feb 2005, [EMAIL PROTECTED] wrote:
I'm trying to figure out how to subclass the list built-in.
. class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
I'm trying to figure out how to subclass the list built-in.
You could do it e.g. like that:
class Mylist (list):
def __init__(self, seq=None):
super(self.__class__, self).__init__(seq)
def __getslice__(self, start, stop):
return