On Wed, May 13, 2009 at 10:00 AM, Alan Gauld wrote:
>
> I may be coming across a bit strong on this one but it is such a
> fundamentally important feature of OOP that I feel on a list like tutor
> it is important to make it clear that this is not only correct behaviour
> but is very common in prac
On Wed, May 13, 2009 at 9:44 AM, spir wrote:
>
>
> Then someone stated that, except for __init__, this should be considered
> wrong. You and Kent disagreed (and indeed I do too).
Yup, that was me. I was incorrect, and am now searching around for writings
on proper OOP design with a python slant
"spir" wrote
But calling the method of a superclass from the same method is very,
very common.
Yep, for sure; and I was not discussing this actually.
(1) In fact, the whole exchange started when the OP asked how to
call 2 different methods on the same object, one beeing defined
on on its ow
Le Tue, 12 May 2009 23:23:02 +0100,
"Alan Gauld" s'exprima ainsi:
> But calling the method of a superclass from the same method is very,
> very common.
[...]
Yep, for sure; and I was not discussing this actually.
(1) In fact, the whole exchange started when the OP asked how to call 2
different
"spir" wrote
Two methods only one message. It is what polymorphism is all about.
Well, I do not want to argue. But this is not what I call polymorphism.
Not "on the same object". Polymorphism as I know it rather dispatches
depending on the object (usually it's actual type).
Yes, the two m
Le Tue, 12 May 2009 17:43:24 +0100,
"Alan Gauld" s'exprima ainsi:
> > Having two methods with the name that both need two be used
> > on the same object is clearly a design flaw. What do you think?
>
> Two methods only one message. It is what polymorphism is all about.
Well, I do not want to
"Jeremiah Dodds" wrote
Ahh, I stand corrected. Perhaps because the shop I work in is primarily
python, and because we strongly favor composition over inheritance, I
never
see (python) classes being used this way.
Composition over inheritance has now become so overused it
is losing one of t
"Jeremiah Dodds" wrote
> That should not happen! Basic contract is: same name = same meaning.
Same meaning yes, but that doesn't mean that I can't/shouldn't reuse
code that address a part of the problem.
If your superclass has a method with the same name (other than __init__
here), that con
"spir" wrote
OK, bad example. But assume I have the same method in both classes and
want to call the method in the parent.
That should not happen! Basic contract is: same name = same meaning.
Nope, its called polymorphism.
The semantics may be the same but the implementation detail may d
Le Tue, 12 May 2009 07:27:52 -0400,
Kent Johnson s'exprima ainsi:
> I don't agree with this at all. It's not at all unusual for a derived
> class to override a base class method in order to add additional
> functionality to it, then to call the base class method to complete
> the implementation.
"Jeremiah Dodds" wrote
Can you give a concrete example of _why_ you would want to do this? You
can
use super, if you really want to, but it can get ugly (I do not fully
understand all of supers caveats). I can't think of a case off the top of
my
head where you would want to call a parent cla
"The Green Tea Leaf" wrote
class Child(Parent):
def somemethod( self, bla ):
Parent.somemethod(self,bla)
or like this
class Child(Parent):
def somemethod( self, bla ):
super(Child,self).somemethod(bla)
The first version seem to have the obvious disadvantage that I need t
On Tue, May 12, 2009 at 2:27 PM, Kent Johnson wrote:
> On Tue, May 12, 2009 at 8:44 AM, Jeremiah Dodds
> wrote:
> > On Tue, May 12, 2009 at 12:27 PM, Kent Johnson wrote:
>
> >> I don't agree with this at all. It's not at all unusual for a derived
> >> class to override a base class method in or
On Tue, May 12, 2009 at 8:44 AM, Jeremiah Dodds
wrote:
> On Tue, May 12, 2009 at 12:27 PM, Kent Johnson wrote:
>> I don't agree with this at all. It's not at all unusual for a derived
>> class to override a base class method in order to add additional
>> functionality to it, then to call the bas
On Tue, May 12, 2009 at 12:27 PM, Kent Johnson wrote:
> On Tue, May 12, 2009 at 6:32 AM, Jeremiah Dodds
> wrote:
>
> > If your superclass has a method with the same name (other than __init__
> > here), that contains some logic that a subclass that overrides the method
> > needs, it's written wro
On Tue, May 12, 2009 at 6:32 AM, Jeremiah Dodds
wrote:
> If your superclass has a method with the same name (other than __init__
> here), that contains some logic that a subclass that overrides the method
> needs, it's written wrong in python. In this case, use different method
> names, or factor
> If your superclass has a method with the same name (other than __init__
> here), that contains some logic that a subclass that overrides the method
> needs, it's written wrong in python. In this case, use different method
> names, or factor out the parent class methods functionality into (probabl
On Tue, May 12, 2009 at 11:02 AM, The Green Tea Leaf <
thegreenteal...@gmail.com> wrote:
> > That should not happen! Basic contract is: same name = same meaning.
>
> Same meaning yes, but that doesn't mean that I can't/shouldn't reuse
> code that address a part of the problem.
>
>
>
If your superc
> That should not happen! Basic contract is: same name = same meaning.
Same meaning yes, but that doesn't mean that I can't/shouldn't reuse
code that address a part of the problem.
> Having two methods with the name that both need two be used on the same
> object is clearly a design flaw. What d
Le Tue, 12 May 2009 10:55:18 +0200,
The Green Tea Leaf s'exprima ainsi:
> OK, bad example. But assume I have the same method in both classes and
> want to call the method in the parent.
That should not happen! Basic contract is: same name = same meaning.
Either you implement a method in a paren
I just want to know what is the best way to do this.
As for an example, I would say the __init__ method where the parent
class do some initialization, to be sure that everything is set up
correctly I would call the parents class __init__ method before doing
something else.
On Tue, May 12, 2009 at 9:55 AM, The Green Tea Leaf <
thegreenteal...@gmail.com> wrote:
> OK, bad example. But assume I have the same method in both classes and
> want to call the method in the parent.
>
>
Can you give a concrete example of _why_ you would want to do this? You can
use super, if yo
OK, bad example. But assume I have the same method in both classes and
want to call the method in the parent.
On Tue, May 12, 2009 at 10:26, Jeremiah Dodds wrote:
>
>
> On Tue, May 12, 2009 at 9:05 AM, The Green Tea Leaf
> wrote:
>>
>> Hi,
>> I've started to learn Python and I'm a bit confused o
On Tue, May 12, 2009 at 9:05 AM, The Green Tea Leaf <
thegreenteal...@gmail.com> wrote:
> Hi,
> I've started to learn Python and I'm a bit confused over how to call a
> method in a parent class. Assume I have:
>
> class Parent(object):
>def somemethod( self, bla ):
>print 'Parent',bla
Hi,
I've started to learn Python and I'm a bit confused over how to call a
method in a parent class. Assume I have:
class Parent(object):
def somemethod( self, bla ):
print 'Parent',bla
I then create a child class that want to call somemethod. As I
understand it I can either do it lik
25 matches
Mail list logo