1 #!/usr/bin/env python 2 3 class C: 4 def x(self): 5 return 1 6 7 class D: 8 def x(self): 9 return 2 10 11 def f(obj, attrname): 12 return getattr(obj, attrname) 13 14 c = C() 15 d = D() 16 result_1 = f(c, "x")() 17 result_2 = f(d, "x")() 18 19 # vim: tabstop=4 expandtab shiftwidth=4