Ich bekomme einen Fehler, den ich nicht herausfinden kann. Irgendwelche Hinweise, was mit meinem Beispielcode nicht stimmt?Super() schlägt mit Fehler fehl: TypeError "Argument 1 muss Typ sein, nicht Classobj"
class B:
def meth(self, arg):
print arg
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
print C().meth(1)
Ich habe die Probe Test-Code von Hilfe von "Super" eingebauten Methode. Die Klasse "C" die hier
ist der Fehler:
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, hier ist die Hilfe (Super-) von Python selbst:
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)
|
möglich duplikat von [python super() löst TypeError! Warum?] (Http://stackoverflow.com/questions/489269/python-super-raises-typeerror-why) – user
Meth? Ist das ein Programmierbegriff oder ... weißt du? Bitte klären Sie. – Cplusplusplus
@Cplusplusplus: wahrscheinlich steht für Methode ;-) – ShadowFlame