[docs] Super function example error?

Joaquin Duo joaduo at gmail.com
Mon Oct 25 21:15:17 CEST 2010


Hi!

My name is Joaquín Duo I am a free software enthusiast.
While I was reading about the super() Buit-in function on:
http://docs.python.org/library/functions.html#super

i found example of the function raises an error on python 2.7.
The example is:
class C(B):
    def method(self, arg):
        super(C, self).method(arg)

In fact I runned it like:
class B:
    def method(self, arg):
        pass


class C(B):
    def method(self, arg):
        super(C, self).method(arg)


c = C()
c.method(10)

Raises:
Funcion_Super.py", line 8, in method
    super(C, self).method(arg)
TypeError: must be type, not classobj

I guess the correction would be
class C(B):
    def method(self, arg):
        super(type(self), self).method(arg)


Cheers!
Joaquín


More information about the docs mailing list