title: Making Commandline Parameters Optional in Python
body: <p>I am using ArgParse for giving commandline parameters in Python.</p>
  
  <pre><code>import argparse
  parser = argparse.ArgumentParser()
  parser.add_argument("--quality", help="enter some quality limit")
  args = parser.parse_args()
  print "You gave quality = %s" % str(args.quality)
  </code></pre>
  
  <p>I saved this as <code>a.py</code> then ran this:</p>
  
  <pre><code>$ python a.py --quality 10
  You gave quality = 10
  </code></pre>
  
  <p>I also want my code to run even if the commandline parameter is not provided.I want to make it optional.And if its provided,then it take a certain specific value which can be used further.</p>
  
  <p>I have something like this in my code :</p>
  
  <pre><code> if int(quality)==10:
  </code></pre>
  
  <p>So if I run without the parameter:</p>
  
  <pre><code> $ python a.py
  </code></pre>
  
  <p>I get this error: </p>
  
  <p>TypeError: int() argument must be a string or a number, not 'NoneType'  </p>