I am trying to retrieve optional command line parameters for a Python script (2.7 under Windows) and things are not going smoothly. The code is:
parser = argparse.ArgumentParser(description = 'Process display arguments')
parser.add_argument('-t', nargs = '?', default = 'baz')
args = parser.parse_args(['-t'])
print args.t
If I run "program.py" with no parameter, args.t is printed as None.
If I run "program.py -t", args.t is printed as None.
If I run "program.py -t foo", args.t is printed as None.
Why am I not getting the value from the command line into args.t?