title: argparse: How to call a method instead of a function?
body: <p>I am using argparse in my python program and I want to call a <strong>method</strong> when I run my software like this :</p>
  
  <pre><code>$ python __init__.py foo
  </code></pre>
  
  <p>It is easy if I want to call a function instead of a method :</p>
  
  <pre><code>def foo(args):
      pass
  
  def main():
      foo_parser.set_defaults(func=foo)
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>How can I replace "func=foo" by "func=MyClass.my_method" ?</p>