title: Call a method of an object with arguments in Python
body: <p>I want to be able to call different methods on a Python class with dynamic function name, e.g.</p>
  
  <pre><code>class Obj(object):
      def A(self, x):
          print "A %s" % x
  
      def B(self, x):
          print "B %s" % x
  
  o = Obj()
  
   # normal route
  o.A(1) # A 1
  o.B(1) # B 1
  
   # dynamically
  foo(o, "A", 1) # A 1; equiv. to o.A(1)
  foo(o, "B", 1) # B 1
  </code></pre>
  
  <p>What is "foo"? (or is there some other approach?) I'm sure it must exist, but I just can't seem to find it or remember what it is called. I've looked at <code>getattr</code>, <code>apply</code>, and others in the <a href="http://docs.python.org/library/functions.html">list of built-in functions</a>. It's such a simple reference question, but alas, here I am!</p>
  
  <p>Thanks for reading!</p>