In a C program, the command-line arguments passed to the program can be accessed using the
argv input parameters to the main function. Accessing the command-line arguments passed to a Python program are easy to access too. These arguments are available as a list named
argv in the sys module. At a minimum, there is at least one argument in this list. This is the first argument, which is the name of the Python script.
This Python program prints out its command-line arguments:
import sys def main(): for arg in sys.argv: print arg if "__main__" == __name__: main()