TheShed

Python Command Line Arguments

Category: Programming
#Python #fragments

A fragment for processing arguments passed from the command line:

import sys
#… stuff
myArg = sys.argv[1]         # argv[0] is the name of the command

For more sophisticated parsing, StackOverflow has recommendations.