| Store | Cart

Calling __init__ with multiple inheritance

From: Robert Dick <dic...@ece.northwestern.edu>
Mon, 28 Mar 2005 13:14:46 -0600
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-

Recent Messages in this Thread
Axel Straschil Mar 28, 2005 12:51 pm
Peter Otten Mar 28, 2005 02:08 pm
jfj Mar 29, 2005 03:27 am
Peter Otten Mar 28, 2005 05:51 pm
jfj Mar 29, 2005 04:53 am
Peter Otten Mar 28, 2005 07:53 pm
Axel Straschil Mar 29, 2005 05:53 am
Steven Bethard Mar 29, 2005 07:02 am
Peter Otten Mar 29, 2005 08:37 am
Axel Straschil Mar 29, 2005 12:21 pm
jfj Mar 29, 2005 07:38 pm
Robert Dick Mar 28, 2005 07:14 pm
phil...@yahoo.com Mar 28, 2005 04:07 pm
Messages in this thread