the first arg to super() must be a type, not a class obj?

Andre Meyer meyer at acm.org
Fri Sep 8 04:01:05 EDT 2006


Another thing: how does super() work wrt. multiple inheritance? It seems
like it returns only the first superclass.

regards
Andre



On 9/8/06, Georg Brandl <g.brandl-nospam at gmx.net> wrote:
>
> metaperl wrote:
> > On p.282 of "Python Cookbook" and in the Python docs on calling super:
> > http://www.python.org/download/releases/2.2.3/descrintro/#cooperation
> >
> > it is clear that the first argument to super is a class and not a type.
> > However, for the code below, I am getting an error when attempting to
> > provide a class as my first argument and don't understand why. Also,
> > since this is my first attempt at writing anything of any seriousness
> > in Python, any other feedback is welcome.
>
> "super" only works for new-style classes.
>
> You could make "ftputilx" new-style by inheriting from object and FTPHost,
> but FTPHost is still old-style, and I don't know if that's okay with
> super.
>
> So in your case it would be advisable to use
>
> FTPHost.__init__(self)
>
> instead of
>
> super(ftputilx, self).__init__()
>
> Georg
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Dr. Andre P. Meyer                        http://python.openspace.nl/meyer
TNO Defence, Security and Safety          http://www.tno.nl/
Delft Cooperation on Intelligent Systems  http://www.decis.nl/

Ah, this is obviously some strange usage of the word 'safe' that I wasn't
previously aware of. - Douglas Adams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060908/ee60bf59/attachment.html>


More information about the Python-list mailing list