Hello!
>> Also, lool at that:
>> class Mother(object):
>> def __init__(self, param_mother='optional', **eat):
>> print 'Mother'
>> class Father(object):
>> def __init__(self, param_father='optional', **eat):
>> print 'Father'
>> class Child(Mother, Father):
>> def __init__(self, **ham):
>> super(C
Peter Otten wrote:
Child()
child
father
mother
parent # <-- parent only once
<__main__.Child object at 0x402ad38c>
D-uh?
class Parent(object):
def __init__(self):
print "parent"
super(Parent, self).__init__()
class Father
Axel Straschil wrote:
> Thanks to all for the very interesting postings!
You're welcome.
> I came to the following:
>
> For single inheritance, super is a nice tool if you will recfactoring
> the class later.
Or if you start out with a diamond inheritance graph from the beginning.
> For mul
Axel Straschil wrote:
I came to the following:
For single inheritance, super is a nice tool if you will recfactoring
the class later.
For multiple inheritance, if you want to use super, you have to have
very much knowledge of the classes you inheritance.
And for multiple inheritance, if you don't
Hello!
Thanks to all for the very interesting postings!
I came to the following:
For single inheritance, super is a nice tool if you will recfactoring
the class later.
For multiple inheritance, if you want to use super, you have to have
very much knowledge of the classes you inheritance. For m
jfj wrote:
> As for the case where the users of the library want to subclass, I don't
> see a problem. They know they must subclass from class XXX and so they
> call XXX.__init__ to construct it.
I was thinking of
class Child(Father, Mother):
pass
where Father and Mother have a common bas
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. T
Peter Otten wrote:
jfj wrote:
Peter Otten wrote:
Here is an alternative approach that massages the initializer signatures
a bit to work with super() in a multiple-inheritance environment:
super(Father, self).__init__(p_father=p_father, **more)
Is there any advantage using super in this cas
[EMAIL PROTECTED] wrote:
What if I want to call other methods as well? Modifying your example a
bit, I'd like the reset() method call of Child to invoke both the
Mother and Father reset() methods, without referencing them by name,
i.e., Mother.reset(self).
---
class Mother(object):
jfj wrote:
> Peter Otten wrote:
>> Here is an alternative approach that massages the initializer signatures
>> a bit to work with super() in a multiple-inheritance environment:
>
>> super(Father, self).__init__(p_father=p_father, **more)
>
>
> Is there any advantage using super in this
Peter Otten wrote:
Here is an alternative approach that massages the initializer signatures a
bit to work with super() in a multiple-inheritance environment:
super(Father, self).__init__(p_father=p_father, **more)
Is there any advantage using super in this case?
I think the case Father._
Peter Otten wrote:
> The problem with that aren't incompatible signatures, but the lack of
an
> implementation of the reset() method at the top of the diamond-shaped
> inheritance graph that does _not_ call the superclass method. That
method
> could be basically a noop:
Ok, now that's cool! Up
[EMAIL PROTECTED] wrote:
> What if I want to call other methods as well? Modifying your example a
> bit, I'd like the reset() method call of Child to invoke both the
> Mother and Father reset() methods, without referencing them by name,
> i.e., Mother.reset(self).
[example snipped]
The problem w
What if I want to call other methods as well? Modifying your example a
bit, I'd like the reset() method call of Child to invoke both the
Mother and Father reset() methods, without referencing them by name,
i.e., Mother.reset(self).
---
class Mother(object):
def __init__(self, p
Axel Straschil wrote:
> Im working with new (object) classes and normaly call init of ther
> motherclass with callin super(...), workes fine.
>
> No, I've got a case with multiple inherance and want to ask if this is
> the right and common case to call init:
>
> class Mother(object):
> def __ini
15 matches
Mail list logo