TypeError: unbound method...expected one instance, got another

Andreas Kostyrka andreas at kostyrka.priv.at
Wed Jul 24 10:38:49 EDT 2002


Am Fre, 2002-07-19 um 01.21 schrieb David:
> I have created a hierarchy of classes, and I am receiving an error that I
> have not been able to figure out.  The error message (in Python 2.2) is:
> "TypeError: unbound method __init__() must be called with Super instance as
> first argument (got Sub instance instead)".
> 
> My situation is that I have three classes in a hierarchy, with the Super
> living in a different module than the Mid and the Sub, as follows:
> 
> module1.class Super:
>                    def __init__(self):
>                         self.a = 'string1'
> 
> module2.class Mid(module1.Super):
>                    def __init__(self):
>                         self.b = 'string2'
>                         module1.Super.__init__(self)
> 
> module2.class Sub(Mid):
>                    def __init__(self):
>                         self.c = 'string3'
>                         Mid.__init__(self)
What are the exact error messages. Exceptions in Python provide always a
backtrace of the execution flow. You also do not make clear how you are
trying to use your modules. Additionally the above pseudo code is
obviously not the exact source. 

Best regards,

Andreas





More information about the Python-list mailing list