Calling __init__ with multiple inheritance

Robert Dick dickrp at ece.northwestern.edu
Mon Mar 28 21:14:46 CEST 2005


jfj:
> In the case of Parent diamond inheritance, super() can avoid calling
> the __init__ of parent twice?  How?

Guido has a nice description of it: 
http://www.python.org/2.2.3/descrintro.html#cooperation.

It linearizes the graph.  Unfortunately, this means that super delegates to 
siblings.  This makes super incompatible with differences in positional 
arguments within a class hierarchy.  If you want a super that works with 
positional arguments, please see delegate.py at 
http://ziyang.ece.northwestern.edu/~dickrp/python/delegate.html (also in 
PyPI).  If others don't find problems with the approach, I hope it becomes 
standard.  I found it distracting that python's default argument passing 
approach conflicts with its default delegation approach.

Good luck,

-Robert Dick-



More information about the Python-list mailing list