class Printer( object ):
def foo( self ):
print "hi"
class MyExec( object ):
def myrun( self, object_instance, method_name ):
print type( object_instance )
if hasattr( object_instance, method_name ):
print "has", method_name
method_to_call = getattr( object_instance, method_name )
print type( method_to_call )
method_to_call()
if __name__ == "__main__":
p = Printer()
p.foo()
me = MyExec()
me.myrun( p, "foo" )