super () kończy się niepowodzeniem z błędem: TypeError „argument 1 musi być typu, a nie classobj”, gdy rodzic nie dziedziczy z obiektu
Dostaję błąd, którego nie mogę zrozumieć. Jakieś wskazówki co jest nie tak z moim kodem przykładowym?
class B:
def meth(self, arg):
print arg
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
print C().meth(1)
Dostałem przykładowy kod testowy z pomocy „super” wbudowanej metody. Klasa „C” to
Oto błąd:
Traceback (most recent call last):
File "./test.py", line 10, in ?
print C().meth(1)
File "./test.py", line 8, in meth
super(C, self).meth(arg)
TypeError: super() argument 1 must be type, not classobj
FYI, oto pomoc (super) z samego Pythona:
Help on class super in module __builtin__:
class super(object)
| super(type) -> unbound super object
| super(type, obj) -> bound super object; requires isinstance(obj, type)
| super(type, type2) -> bound super object; requires issubclass(type2, type)
| Typical use to call a cooperative superclass method:
| class C(B):
| def meth(self, arg):
| super(C, self).meth(arg)
|