Ich versuche, die Funktion super() in Python zu lernen.Verwenden Super mit einer Klassenmethode
Ich hatte zwar einen Griff davon, bis ich über dieses Beispiel (2.6) kam und feststeckte.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 9, in do_something
do_something = classmethod(do_something)
TypeError: unbound method do_something() must be called with B instance as first argument (got nothing instead)
>>>
Es war nicht das, was ich erwartet hatte, wenn ich diese Zeile lesen direkt vor dem Beispiel:
If we're using a class method, we don't have an instance to call super with. Fortunately for us, super works even with a type as the second argument. --- The type can be passed directly to super as shown below.
das ist genau das, was Python mir sagt, ist nicht möglich, dass do_something sagen() sollte mit einer Instanz von B aufgerufen werden.
Vielen Dank im Voraus
Mögliche Duplikat [Aufruf einer Basisklasse classmethod in Python] (https://stackoverflow.com/questions/1269217/calling-a-base-classs-classmethod-in-python) –