Calling __init__ with multiple inheritance

Axel Straschil axel at straschil.com
Tue Mar 29 07:53:39 CEST 2005


Hello!

Thanks to all for the very interesting postings!

I came to the following:

For single inheritance, super is a nice tool if you will recfactoring
the class later. 

For multiple inheritance, if you want to use super, you have to have
very much knowledge of the classes you inheritance. For me, OOP is to
not have to have the deep inner knowledge of the classes I inheritance
from. 

Also, for multiple inheritance, if think 
Mother1.__init__(self, ...)
Mother2.__init__(self, ...)
Mother3.__init__(self, ...)
would be more clear to read then
super(MyClass).__init__(Maby this will do some magic thing)

Also, I realy dislike 
__init__(self, param, **eat_some_needless_stuff)

If I later extend my class and also add some parameters to __init__,
what will happen to the classes using the baseclass?

Also, lool at that:
class Mother(object):
	def __init__(self, param_mother='optional', **eat): 
		print 'Mother'
class Father(object):
	def __init__(self, param_father='optional', **eat): 
		print 'Father'
class Child(Mother, Father):
	def __init__(self, **ham): 
		super(Child, self).__init__(**ham)
child = Child(param_mother=1, param_father=1)

Father's init will not be called.

Thanks,
AXEL.
-- 
"Aber naja, ich bin eher der Forentyp." Wolfibolfi's outing in 
http://www.informatik-forum.at/showpost.php?p=206342&postcount=10



More information about the Python-list mailing list