title: How to parse arguments to a function in Python?
body: <p>I've been trying to understand tutorials on how to parse arguments in Python using argparse. Is this how I would pass a command line input so I can run a function?</p>
  
  <pre><code>import argparse
  
  parser = argparse.ArgumentParser(description='A test')
  parser.add_argument("--a", default=1, help="Test variable")
  
  args = parser.parse_args()
  
  def foo():
      command_line_argument = args.a
      bar = 2*args.a
      print(bar)
      return
  
  if "__name__" == "__main__" 
      try:
          while True:
          foo()
      except KeyboardInterrupt:
          print('User has exited the program')
  </code></pre>