title: Run a specific function when an argument is specified using - argparse
body: <p>Hi Everyone so I have read all of the "similar" posts and have not found a clear answer. What is the most simple way to map an argument to a specific function I have defined?</p>
  
  <pre><code>parser = argparse.ArgumentParser(" ")
  
  parser.add_argument("-u", "--url")
  parser.add_argument("-i", "--ip")
  parser.add_argument("-a", "--action")
  args = parser.parse_args()
  
  def func1(ip):
      do something
  func1(ip)
  
  def func2(url):
      do something
  func1(url)
  
  def func3(action):
      do something
  func1(action)
  </code></pre>
  
  <p>My functions work properly with the arguments, but I do not want say func2 &amp; func3 to run if the -u flag is used, or I only want func3 to run if -a is used. In laymans terms is this possible? The other answers were not clear at all.</p>
  
  <p>Thanks!</p>