Commandline Arguments are used primarily to pass arguments to your code when you start your program, for instance:
I'm now going to walk through producing this extremely useful (:-)) program shown above. I'm going to show a simple way to do arguments which is useful for many smaller programs. Larger programs that require more then 2 or 3 arguments should probably look into using the getopt and optparse modules.
If you're looking do duplicate how many nicer commandline programs supply arguments like --help and so on, you will also want to take a look at the getopt and optparse modules. getopt is easier to get started with, but is less sophisticated. It requires a little more work to create a nice interface. optparse has a nice object oriented design and provides a lot of powerful options and can handle a lot of options with not much code.
The key thing to keep in mind here is the use of sys module, and the sys.argv parameter. The length of sys.argv is at least 1, where sys.argv[0] is the first argument passed to the python interpreter. That will pretty much always be the name of your script. So the first real commandline argument is actually the second argument in the sys.argv list.
This method for dealing with commandline arguments is awkward and somewhat painstaking. Notice how we have to have special cases dealing with the number of arguments and things like that. Don't forget that for more complex option lists there are a couple alternative modules that can be used to make life a little easier.
getopt is simpler then optparse, but less powerful.