Zest.

Python: Command-line arguments

A short, tested Python example for command-line arguments. Copy it and adjust the names and paths for your project.

Python
import argparse

p = argparse.ArgumentParser(description="Example")
p.add_argument("path")
p.add_argument("-v", "--verbose", action="store_true")
p.add_argument("--count", type=int, default=1)
args = p.parse_args()

print(args.path, args.verbose, args.count)

Find it in Zest

Search for “python command-line arguments” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Python examples

All Python examples