t274.py 182 B

12345678
  1. class X: pass
  2. x = X()
  3. methodName = "wee"
  4. try:
  5. stuff = getattr(x, methodName)
  6. except AttributeError:
  7. raise ValueError, "no such method in %s: %s" % (x.__class__, methodName)