Re: [Tutor] list.__init__ within class definition

2011-04-21 Thread Alan Gauld
"Alex Companioni" wrote class Tomato(list): def __init__(self, data): list.__init__(self, data) The list.__init__ method (if it is a method, I'm not clear on what __init__ actually *is*) creates a list, right? Not quite. __init__ (which is a method) is an initialiser not a const

Re: [Tutor] list.__init__ within class definition

2011-04-21 Thread Alan Gauld
"James Mills" wrote What you actually want is this: class Tomato(list): ... def __init__(self, data): ... super(Tomato, self).__init__(data) ... l = Tomato([1, 2, 3]) l [1, 2, 3] Your example: class Tomato(list): ... def __init__(self, data): ... list

Re: [Tutor] list.__init__ within class definition

2011-04-20 Thread James Mills
On Thu, Apr 21, 2011 at 1:21 PM, Alex Companioni wrote: > In the following class definition: > > class Tomato(list): >    def __init__(self, data): >        list.__init__(self, data) > > The list.__init__ method (if it is a method, I'm not clear on what > __init__ actually *is*) creates a list, ri

[Tutor] list.__init__ within class definition

2011-04-20 Thread Alex Companioni
Hey there, In the following class definition: class Tomato(list): def __init__(self, data): list.__init__(self, data) The list.__init__ method (if it is a method, I'm not clear on what __init__ actually *is*) creates a list, right? In other words, l = Tomato([1,2,3]) will create a

Re: [Tutor] list.__init__()

2006-01-26 Thread Kent Johnson
Christopher Spears wrote: > What purpose does list.__init__() play in the piece of > code below? It's an incorrect call to the base class __init__() function. This does base class initialization on the current list. The correct call is list.__init__(self) By the way this list seems to be doin

[Tutor] list.__init__()

2006-01-26 Thread Christopher Spears
What purpose does list.__init__() play in the piece of code below? class Mylist(list): def __init__(self, value = []): list.__init__([]) self.concat(value) def concat(self, value): for x in value: if not x in s