In Python, is there a way to specify an unlimited number of arguments to a command line option ? For example something like python myscript.py --use-files a b c d e. Note that I strictly want to use a command line option e.g. I don’t just want python myscript.py a b c d e
In Python, is there a way to specify an unlimited number of arguments to
Share
Command-line options are simple with stdlib argparse module. Using
nargs="*"allows arbitrarily many arguments to be supplied for an option:Outputs: