S
Stef Mientki
hello,
although this is not a real problem for me,
it was caused by a copying, instead of moving, a piece of code.
But I don't understand at all why the code below gives the error.
class derived_class, is defined twice,
the error is cuase by the second instance creation "test2="
for me even weirder, if I create test2 in another module, everything
works perfect ???
Any explanation would be welcome.
thanks,
Stef Mientki
==== start of code ===
class base_class ( object ) :
def __init__ ( self ) :
pass
class derived_class ( base_class ) :
def __init__ ( self ) :
base_class.__init__ ( self )
class final_class_1 ( derived_class ) :
def __init__ ( self ) :
derived_class.__init__ ( self )
test1 = final_class_1 ()
class derived_class ( base_class ) :
def __init__ ( self ) :
base_class.__init__ ( self )
test2 = final_class_1 ()
==== end of code =====
==== error meassage =====
Traceback (most recent call last):
File "D:\Data_Python_25\PyLab_Works\module1.py", line 19, in <module>
test2 = final_class_1 ()
File "D:\Data_Python_25\PyLab_Works\module1.py", line 11, in __init__
derived_class.__init__ ( self )
TypeError: unbound method __init__() must be called with derived_class
instance as first argument (got final_class_1 instance instead)
although this is not a real problem for me,
it was caused by a copying, instead of moving, a piece of code.
But I don't understand at all why the code below gives the error.
class derived_class, is defined twice,
the error is cuase by the second instance creation "test2="
for me even weirder, if I create test2 in another module, everything
works perfect ???
Any explanation would be welcome.
thanks,
Stef Mientki
==== start of code ===
class base_class ( object ) :
def __init__ ( self ) :
pass
class derived_class ( base_class ) :
def __init__ ( self ) :
base_class.__init__ ( self )
class final_class_1 ( derived_class ) :
def __init__ ( self ) :
derived_class.__init__ ( self )
test1 = final_class_1 ()
class derived_class ( base_class ) :
def __init__ ( self ) :
base_class.__init__ ( self )
test2 = final_class_1 ()
==== end of code =====
==== error meassage =====
Traceback (most recent call last):
File "D:\Data_Python_25\PyLab_Works\module1.py", line 19, in <module>
test2 = final_class_1 ()
File "D:\Data_Python_25\PyLab_Works\module1.py", line 11, in __init__
derived_class.__init__ ( self )
TypeError: unbound method __init__() must be called with derived_class
instance as first argument (got final_class_1 instance instead)