getattr
Código Python:
Ver originalclass A:
def __init__(self, a):
self.a = a
def some_method(self):
print self.a
x = A('a')
y = A('b')
s = getattr(x, 'some_method')
s()
s = getattr(y, 'some_method')
s()
try:
s = getattr(y, 'no_method')
except AttributeError:
print "no_method no es un atributo"