"The command line arguments are treated as a list, which is
accessible by referencing sys.argv. The first element of the list
is the name of the script and the remaining elements are the
arguments passed in after the script name. If I wanted to, I could
figure out what options I wanted to take, iterate through sys.argv,
and map what the user gave me to the options I wanted to handle. I
could do that, but it would be wasted time.
"There is a better way. A much better way. It's called
"With optparse, you declaratively build up an option parser by
adding the behavior you want it to exhibit when it sees various
options. Here's a simple example of a script that uses
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.