Re: [Tutor] Calling instance method using a string

2006-11-09 Thread Bernard Lebel
Thanks everyone for the advice. Bernard On 11/9/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > >> Say I have class A: > >> > >> class A: > >> def myMethod( self ): > >> print 'foo' > >> > >> a = A() > > > > getattr(a, 'myMethod')() > > > > The getattr() call gets the bound method, the

Re: [Tutor] Calling instance method using a string

2006-11-09 Thread Danny Yoo
>> Say I have class A: >> >> class A: >> def myMethod( self ): >> print 'foo' >> >> a = A() > > getattr(a, 'myMethod')() > > The getattr() call gets the bound method, the extra parentheses at the > end call it. Hi Bernard, You can also do this in a controlled manner by treating the

Re: [Tutor] Calling instance method using a string

2006-11-09 Thread Kent Johnson
Bernard Lebel wrote: > Hello, > > Is there a way to call an instance method using a string? Let say I > have the method name in the form of a string, and I want to call this > method by providing the string instead of calling the name directly. > Is this possible? > > Say I have class A: > > cla

[Tutor] Calling instance method using a string

2006-11-09 Thread Bernard Lebel
Hello, Is there a way to call an instance method using a string? Let say I have the method name in the form of a string, and I want to call this method by providing the string instead of calling the name directly. Is this possible? Say I have class A: class A: def myMethod( self ): p