Re: Things to know about super (was: super() and multiple inheritance failure)

2009-09-27 Thread Dieter Maurer
Michele Simionato writes on Fri, 25 Sep 2009 22:58:32 -0700 (PDT): > ... >You know that in an ideal world I would just > throw > away multiple inheritance, it is just not worth the complication. I am a fan of multiple inheritance: it lets the compliler/language runtime do stupid tasks (implement

Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 8:02 am, "Gabriel Genellina" wrote: > If you decide at every invocation which method to call, it's a dispatcher;   > you may use a dictionary to map each alternative to the function to be   > invoked. If it only depends on the type of the argument, there is a hidden   > gem in pkgutil (

Re: super() and multiple inheritance failure

2009-09-25 Thread Chris Rebert
On Fri, Sep 25, 2009 at 9:30 PM, Steven D'Aprano wrote: > On Fri, 25 Sep 2009 20:15:54 -0700, Chris Rebert wrote: > >>> Inside MyClass().method(n), I dispatch to either NClass.method() or >>> PClass.method() depending on the value of the argument n. The correct >>> class is called, but then the *o

Re: super() and multiple inheritance failure

2009-09-25 Thread Gabriel Genellina
En Sat, 26 Sep 2009 01:48:08 -0300, Steven D'Aprano escribió: I'm aiming for some sort of polymorphic inheritance: in a method, if the argument meets some condition, inherit from PClass, if it meets another condition inherit from NClass, and so on. Is there are standard name for this idea?

Re: super() and multiple inheritance failure

2009-09-25 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 25 Sep 2009 21:03:09 -0700, Michele Simionato wrote: > > I usually recommend avoiding multiple inheritance altogether. > > In my case, PClass and NClass are actually private classes, and it > seemed like a nice way to avoid having to fill MyClass with > slightly-

Things to know about ‘super’ (was: super() and multiple inheritance failure)

2009-09-25 Thread Ben Finney
Michele Simionato writes: > You may want to read "Things to know about super": > > http://www.artima.com/weblogs/viewpost.jsp?thread=236275 > http://www.artima.com/weblogs/viewpost.jsp?thread=236278 > http://www.artima.com/weblogs/viewpost.jsp?thread=237121 Thanks for these articles. Any chance

Re: super() and multiple inheritance failure

2009-09-25 Thread Steven D'Aprano
On Fri, 25 Sep 2009 21:03:09 -0700, Michele Simionato wrote: > On Sep 26, 4:36 am, Steven D'Aprano cybersource.com.au> wrote: >> I don't understand why I'm getting the following behaviour when using >> super() with multiple inheritance. > > super is working as intended. If you do not want cooper

Re: super() and multiple inheritance failure

2009-09-25 Thread Steven D'Aprano
On Fri, 25 Sep 2009 20:15:54 -0700, Chris Rebert wrote: >> Inside MyClass().method(n), I dispatch to either NClass.method() or >> PClass.method() depending on the value of the argument n. The correct >> class is called, but then the *other* class method is called as well. >> E.g. this is what I ex

Re: super() and multiple inheritance failure

2009-09-25 Thread Daniel Stutzbach
On Fri, Sep 25, 2009 at 9:36 PM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > I don't understand why I'm getting the following behaviour when using > super() with multiple inheritance. The following is a minimal example > demonstrating the behaviour. > super() does not have th

Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 4:36 am, Steven D'Aprano wrote: > I don't understand why I'm getting the following behaviour when using > super() with multiple inheritance. super is working as intended. If you do not want cooperative methods, don't use super and call directly the superclass. I usually recommend avoid

Re: super() and multiple inheritance failure

2009-09-25 Thread Chris Rebert
On Fri, Sep 25, 2009 at 7:36 PM, Steven D'Aprano wrote: > I don't understand why I'm getting the following behaviour when using > super() with multiple inheritance. The following is a minimal example > demonstrating the behaviour. > > I have a diamond class hierarchy as follows: > >  o >  | >  B >

super() and multiple inheritance failure

2009-09-25 Thread Steven D'Aprano
I don't understand why I'm getting the following behaviour when using super() with multiple inheritance. The following is a minimal example demonstrating the behaviour. I have a diamond class hierarchy as follows: o | B / \ P N \ / M where: o = object B = BaseClass P = PClass N = NClass M

Re: super() and multiple inheritance

2005-12-02 Thread Michele Simionato
Hermy: > So, for the moment my conclusion is that although Python has some > syntax for multiple inheritance, it doesn't support it very well, and I should > probably stick to single inheritance. This is not much a problem of Python, the problem is that multiple inheritance is intrinsically HARD t

Re: super() and multiple inheritance

2005-12-01 Thread Carl Banks
hermy wrote: > Thanx, I think I got it (please correct me if I'm wrong): > o super(C,self) determines the next class in the inheritance hierarchy > according to > method resolution order, and simply calls the specified method on it > (in this case > __init__ with the specified argument list. > o

Re: super() and multiple inheritance

2005-12-01 Thread hermy
Carl Banks schreef: > hermy wrote: > > Hi, > > I'm trying to figure out how to pass constructor arguments to my > > superclasses in a multiple inheritance situation. > > > > As I understand it, using super() is the preferred way to call > > the next method in method-resolution-order. When I have

Re: super() and multiple inheritance

2005-12-01 Thread Carl Banks
hermy wrote: > Hi, > I'm trying to figure out how to pass constructor arguments to my > superclasses in a multiple inheritance situation. > > As I understand it, using super() is the preferred way to call > the next method in method-resolution-order. When I have parameterless > __init__ methods, t

Re: [newbie] super() and multiple inheritance

2005-12-01 Thread Steven Bethard
hermy wrote: > As I understand it, using super() is the preferred way to call > the next method in method-resolution-order. When I have parameterless > __init__ methods, this works as expected. > However, how do you solve the following simple multiple inheritance > situation in python ? > > class

[newbie] super() and multiple inheritance

2005-12-01 Thread hermy
Hi, I'm trying to figure out how to pass constructor arguments to my superclasses in a multiple inheritance situation. As I understand it, using super() is the preferred way to call the next method in method-resolution-order. When I have parameterless __init__ methods, this works as expected. Howe