"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
"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
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
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
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
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