[Tutor] list.__init__ within class definition

Alex Companioni achompas at gmail.com
Thu Apr 21 05:21:12 CEST 2011


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 list l with the values [1,2,3], correct?

Thanks,
Alex




More information about the Tutor mailing list