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

2009-09-28 Thread Dieter Maurer
Michele Simionato michele.simion...@gmail.com 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

Re: super() and multiple inheritance failure

2009-09-26 Thread Gabriel Genellina
En Sat, 26 Sep 2009 01:48:08 -0300, Steven D'Aprano st...@remove-this-cybersource.com.au 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

Re: super() and multiple inheritance failure

2009-09-26 Thread Chris Rebert
On Fri, Sep 25, 2009 at 9:30 PM, Steven D'Aprano st...@remove-this-cybersource.com.au 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

Re: super() and multiple inheritance failure

2009-09-26 Thread Michele Simionato
On Sep 26, 8:02 am, Gabriel Genellina gagsl-...@yahoo.com.ar 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  

Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 4:36 am, 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. super is working as intended. If you do not want cooperative methods, don't use super and call directly

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

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 expect:

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 st...@remove-this- 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

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

2009-09-25 Thread Ben Finney
Michele Simionato michele.simion...@gmail.com 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

Re: super() and multiple inheritance failure

2009-09-25 Thread Ben Finney
Steven D'Aprano st...@remove-this-cybersource.com.au 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

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 to

[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.

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

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, this

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: 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 since