I would like to have the following syntax:
python utility.py file1 FILE1 file2 FILE2
where file1 and file2 are optional arguments. It is si
Had same problem. My workaround is:
lastarg = sys.argv[-1]
if len(sys.argv) > 1 and lastarg[0] != '-':
sys.argv[-1] = '-file'
sys.argv.append(lastarg)
argparser = argparse.ArgumentParser()
argparser.add_argument('-d', action='store_true')
argparser.add_argument('-nrv', action='store_true')
argparser.add_argument('-file', type=str, default='')
args = argparser.parse_args()