title: Use argparse to call different functions
body: <p>I am new on Argparse module. I have almost finished my script but there is something I cannot find a way to do it.</p>
  
  <p>Here is the script:</p>
  
  <pre><code>import argparse
  
  def function1(a, b, c):
      #mystaff
  def function2(e, f):
      #mystaff
  def function3(g):
      #mystaff
  
  if __name__ == '__main__':
  
      parser = argparse.ArgumentParser(description='blahblah')
      parser.add_argument('-a','--a', help='blahblah', required=False, default="defaultvalue")
      parser.add_argument('-b','--b', help='blahblah', required=False)
      .......
  
      args = parser.parse_args()
      function1(args.a,args.b,args.c)
  </code></pre>
  
  <p>I want to call the script from command prompt. Now, I can use this for example to call the <code>function1</code>:
  <code>python myscript.py -a &lt;var&gt;</code></p>
  
  <p>What I want is:</p>
  
  <p><code>python myscript.py -a &lt;var&gt;</code>: call the function1 as it is now</p>
  
  <p><code>python myscript.py function2 -c &lt;var&gt;</code>: call the function2 only</p>
  
  <p><code>python myscript.py function3 -g &lt;var&gt;</code>: call the function3 only</p>
  
  <p>So, if I don't specify the function, function1 is the default, otherwise I have to pass the function name from the command prompt too. Any ideas?</p>