free and open-source Python module that facilitates use of command line arguments with Python scripts


Linux commands generally take one or more command line arguments to pass relevant information or modify behavior. argparse adds similar functionality to Python scripts. The script writer can easily specify whether an argument is mandatory, which arguments may be used together, etc. Error messages for the script user are informative and automatically generated.

argparse is especially powerful when combined with a module like subprocess — code in one script can call another script multiple times, varying the set of arguments passed each time. Similar functionality is available in C++ with a library like Boost.Program_options.