Print command line arguments with argparse?

ArgumentParser.parse_args by default takes the arguments simply from sys.argv. So if you don’t change that behavior (by passing in something else to parse_args), you can simply print sys.argv to get all arguments passed to the Python script:

import sys

Alternatively, you could also just print the namespace that parse_args returns; that way you get all values in the way the argument parser interpreted them:

args = parser.parse_args()

Leave a Comment