the first arg to super() must be a type, not a class obj?
Georg Brandl
g.brandl-nospam at gmx.net
Fri Sep 8 03:51:29 EDT 2006
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
More information about the Python-list
mailing list