here is short interactive unix session that shows how the previous code workspython foo py - usagefoo py [optionsoptions- --help show this help message and exit - - outfile--outfile=outfile - debug--debuglevel=debug --speed=speed --coord=coord --novice --guru python foo py - - outfile dat - --coord --speed=ludicrous blah tracing true outfile outfile dat debug speed ludicrous coord ( mode novice args ['blah'python foo py --speed=insane usagefoo py [optionsfoo py:error:option --speed:invalid choice:'insane(choose from 'slow''fast''ludicrous'notes when specifying option namesuse single dash to specify short name such as '-xand double-dash to specify long name such as '--excludean optionerror exception will be raised if you attempt to define an option that is mix of the two stylessuch as '-excluden python also includes module getopt that provides support for command-line parsing in style similar to library of the same name for all practical purposesthere is no benefit to using that module over optparse (which is much higher level and requires far less codingn the optparse module contains considerable number of advanced features related to customization and specialized handling of certain kinds of commandline options howevernone of these features are required for the most common types of command-line option parsing readers should consult the online library documentation for more details and additional examples os the os module provides portable interface to common operating-system services it does this by searching for an os-dependent built-in module such as nt or posix and exporting the functions and data as found there unless otherwise notedfunctions are available on windows and unix unix systems include both linux and mac os lib fl ff