Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Kayode Odeyemi
On Tue, Sep 13, 2011 at 8:31 PM, Dave Angel wrote: > I suspect you're just confused by things the interactive session is > printing out, which are not part of the language, and work a bit > differently. You are right. This is where I missed it. The command interface requires a print command, as

Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Kayode Odeyemi wrote: When an instance of a class is created, all codes within that instance block should be executed. That's my understanding of OOP. I don't understand this phrasing at all. Could you show a specific example of something that does not execute code

Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Ian Kelly
On Tue, Sep 13, 2011 at 10:56 AM, Kayode Odeyemi wrote: class B(A): > ...     def __init__(self, module): > ...             self.module = A.log(self, module) > ...             print self.module # printing here is completely unnecessary > in a good OOP language > ... c = B('system') > log

Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Kayode Odeyemi
On Tue, Sep 13, 2011 at 5:46 PM, Prasad, Ramit wrote: > >You should be passed super the current class you want the super class of, > not the type of the super class. So it should be: > > >super(*B*, self).log('system') # Notice that it passed class B > > ** ** > > Ugh, apologies for the po

RE: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Prasad, Ramit
>You should be passed super the current class you want the super class of, not >the type of the super class. So it should be: >super(B, self).log('system') # Notice that it passed class B Ugh, apologies for the poor English; my tea has not kicked in. That first line would be more understandable

RE: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Prasad, Ramit
Written by Kayode Odeyemi Well, I did try using super(), but I got this: >>> class B(A): ... def __init__(self, module): ... super(A, self).log('system') ... >>> c = B('module') = You should be passed super the current class you want t

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Andreas Perstinger
On 2011-09-11 13:17, Kayode Odeyemi wrote: On Sun, Sep 11, 2011 at 11:41 AM, Thomas Jollans wrote: It is working: >>> class A(object): ... def log (self, module): ... return str ('logged') ... >>> class B(A): ... def __init__(self, module): ... self.module = A

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Kayode Odeyemi wrote: Hello friends, An instance of my subclass doesn't invoke its superclass method, except when it is referenced directly. Here is what I mean: class A(object): ... def log(self, module): ... return str('logged') ... class B(A):

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Thomas Jollans
On 11/09/11 13:17, Kayode Odeyemi wrote: > On Sun, Sep 11, 2011 at 11:41 AM, Thomas Jollans > wrote: > > It is working: > > >>> class A(object): > ... def log (self, module): > ... return str ('logged') > ... > >>> class B(A): > ..

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Kayode Odeyemi
On Sun, Sep 11, 2011 at 11:41 AM, Thomas Jollans wrote: > On 11/09/11 10:18, Kayode Odeyemi wrote: > > Hello friends, > > > > An instance of my subclass doesn't invoke its superclass method, except > > when it is referenced > > directly. > > > > Here is what I mean: > > > class A(object): >

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Thomas Jollans
On 11/09/11 10:18, Kayode Odeyemi wrote: > Hello friends, > > An instance of my subclass doesn't invoke its superclass method, except > when it is referenced > directly. > > Here is what I mean: > class A(object): > ... def log(self, module): > ... return str('logged') > ..

Invoke a superclass method from a subclass constructor

2011-09-11 Thread Kayode Odeyemi
Hello friends, An instance of my subclass doesn't invoke its superclass method, except when it is referenced directly. Here is what I mean: >>> class A(object): ... def log(self, module): ... return str('logged') ... >>> class B(A): ... def __init__(self, module): ...