I have two classes
class Something(object): def __init__(self): self.thing = "thing" class SomethingElse(Something): def __init__(self): self.thing = "another" as you can see, one inherits from another. When I run super(SomethingElse), no error is thrown. However, when I run super(SomethingElse).__init__(), I was expecting an unbound function call (unbound to a hypothetical SomethingElse instance) and so was expecting that __init__() would complain about not receiving an object for its self parameter, but instead I get this error:
TypeError: super() takes at least 1 argument (0 given) What is the meaning of this message?
EDIT: I often see people hand-wave answer a super question, so please don't answer unless you really know how the super delegate is working here, and know about descriptors and how they are used with super.
EDIT: Alex suggested I update my post with more details. I'm getting something different now in both ways I used it for 3.6 (Anaconda). Not sure what is going on. I don't receive what Alex did, but I get:
class Something(object): def __init__(self): self.thing = "thing" class SomethingElse(Something): def __init__(self): super(SomethingElse).__init__() The calls (on Anaconda's 3.6):
SomethingElse() <no problem> super(SomethingElse).__init__() Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: super(): no arguments super(SomethingElse).__init__(SomethingElse()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: super() argument 1 must be type, not SomethingElse My understanding of super was that, according to https://docs.python.org/3/library/functions.html#super, that super() with just the first argument would leave the super object unbounded to an instance, so that if you called __init__() on the super object, you'd need to pass in an instance as __init__() would be unbounded as well. However, 3.6 complains about how, with super(SomethingElse).__init__(SomethingElse(), SomethingElse isn't a type, which it should be as it inherits from a parent that inherits from object.
on 2.7.13 gives the original error for super(SomethingElse).__init__(), which was TypeError: super() takes at least 1 argument (0 given). For super(SomethingElse).__init__(SomethingElse()) it throws TypeError: super() argument 1 must be type, not SomethingElse
super(SomethingElse).__init__()- it will save some time trying to reproduce the error. Side note: I cannot reproduce the error on Python 2.7 - I getTypeError: unbound method __init__() must be called with SomethingElse instance as first argument (got nothing instead)- thank you!