Calling class method by name passed in variable

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri May 23 03:18:33 EDT 2008


Sagari a écrit :
> Greetings,
> 
> Can someone suggest an efficient way of calling method whose name is
> passed in a variable?
> 

method = getattr(obj, 'method_name', None)
if callable(method):
     method(args)



More information about the Python-list mailing list