[Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Brian van den Broek
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] .

Re: [Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Karl =?iso-8859-1?Q?Pfl=E4sterer?=
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)) .

Re: [Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Kent Johnson
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,

Re: [Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Brian van den Broek
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

Re: [Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Danny Yoo
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