[Tutor] OO newbie

BRINER Cedric work at infomaniak.ch
Fri Apr 8 10:55:11 CEST 2005

> > 1-
> > this exemple will also works if you replace the:
> > super(C,self).__init__( *args, **kw)
> > by
> > dict.__init__(self, *args, **kw)
> >
> > but I do not understand this dict.__init_... call.
> > Shouldn't you call the super class constructor??
> super is just a convenience feature added to make Python slightly
> more like some other OOP languages. It is effectively just a
> wrapper around the explicit call to the super class:
> Thus super(C,self...) is the same as
> dict.__init__(self...)
after you telling me that dict.__init__(self...) should in your opinion
the way to do it.
I was not really happy because I did not understand at all this line.
I start looking at this line for a while before understanding it (2
hours maybe)...  :B

<type 'type'>
so dict is a class

dict.__init__ is the function to initialize a dictionnary
dict.__init__(self...) initialize the dictionnary `self'. Which work
because self derive from a dictionnary...

I got it !
I was really lost because I was not clearly making a difference between
the class: ``dict'' and an instance of it: ``dict()''

and thanks for your time.


More information about the Tutor mailing list