sys.argv

noun

say it: “SIS dot ARG-vee” /ˈsɪs dɑt ˈɑrɡvi/

In Python, the list of words typed to start the program: the script's name, then each word after it, all as text.

What is sys.argv?

sys.argv is the list of words a Python program was started with: the script's name first, then each word typed after it, all as strings.

# greet.py, run with: python greet.py Ana 3
import sys
print(sys.argv)   # ['greet.py', 'Ana', '3']

In a sentence

  • “Every value in sys.argv is a string, so the number of days needs int().”
  • “The script reads the folder to sort from sys.argv.”

Level: Journeyman · More Python terms at this level

Updated