Writing command-line tools in Python: argument parsing

1 · Marc Päpper · June 23, 2019, 3:28 p.m.
Python is a great language to build command-line tools in as it’s very expressive and concise. You want to have the ability to parse arguments in your scripts as you don’t want to hard-code the relevant variable values to make the tool useful. So how do we go about this in Python? It’s easily done using the argparse module. With argparse, you define the different arguments which you expect, their default values and their shortcuts to call them....