Command-Line Argument

noun

say it: “kuh-MAND LYNE AR-gyoo-ment” /kəˈmænd ˈlaɪn ˈɑrɡjəmənt/

A word typed after a program's name when it's started from the terminal, which the program reads to know what to work on.

What is a command-line argument in Python?

A command-line argument is a word typed after a script's name when you start it, such as a folder name. The script reads it from sys.argv or with argparse.

python sort_downloads.py Downloads --dry-run
# two command-line arguments: Downloads and --dry-run

In a sentence

  • “She passed the number of days as a command-line argument.”
  • “The folder to sort is a command-line argument, so the script works on any folder.”

Level: Apprentice · More Python terms at this level

Updated

In other subjects