Passing user's args to Python

Sample code for passing user’s args to Python program

1
2
3
4
5
6
7
8
9
10
import argparse

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='')
parser.add_argument('-arg1', type=str, nargs=None)
parser.add_argument('-arg2', type=str, nargs=None)
args = parser.parse_args()
a = args.arg1
b = args.arg2
main(a, b)