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
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 (
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
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?
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-
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
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
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
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
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
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
>
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
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
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
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
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
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
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
18 matches
Mail list logo