How to Add Command-Line Options to a Python Script with argparse
A script that reads its settings from the command line can be run in many ways without editing it. argparse, part of Python's standard library, turns a few lines of description into options, type checks, error messages and a --help page. This guide builds a small greeting script with an argument, an option and a flag, with real output from Python 3.15.2.
