[Tutor] Calling instance method using a string
3dbernard at gmail.com
Thu Nov 9 16:24:01 CET 2006
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:
def myMethod( self ):
a = A()
Then I would look to do something along the lines of:
a.__call__( 'myMethod' )
callattr( a, 'myMethod' )
More information about the Tutor