title: How to make a python script work with and without arguments (default arguments)?
body: <p>I am trying to get a Python script to work regardless when an argument has been passed or not.</p>
  
  <p>The goal is to make the script functional as "MyPython.py" and "MyPython.py 5" should be able to work. If no argument has been passed, then the argument should be 0.</p>
  
  <p>The variable <code>imported_number</code> should by default be 0 but if an argument has been detected, then it should take whatever number the user has passed.</p>
  
  <pre><code>import argparse
  
  imported_number=0
  
  parser = argparse.ArgumentParser()
  parser.add_argument("opt_number", type=int, help="Provide a number please")
  args = parser.parse_args()
  
  if args.opt_number &gt; 0:
      imported_number=args.opt_number
      print "You provided me with the number " + imported_number
      print "You provided me with the number {}".format(args.opt_number)
  else:
      print "You did not provide me with any number. Taking the default value, which is " + imported_number
  </code></pre>
  
  <p>Unfortunately I am getting the <code>error: too few arguments</code> error message.</p>
  
  <p>Does anyone know of good and automated methods to get this task done? I'd appreciate it.</p>