convert a string to a method call ?

Neal Norwitz neal at
Thu Nov 15 17:45:14 CET 2001

Bruce Edge wrote:
> I have an object, say xObj, which has a bunch of methods.
> I have the method I want to call in a string, say str.
> How do I call method str on xObj?

method = getattr(xObj, 'str')
method() # or apply(method)


More information about the Python-list mailing list