I am using ArgParse for giving commandline parameters in Python.
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)
I saved this as a.py
then ran this:
$ python a.py --quality 10
You gave quality = 10
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.
I have something like this in my code :
if int(quality)==10:
So if I run without the parameter:
$ python a.py
I get this error:
TypeError: int() argument must be a string or a number, not 'NoneType'