O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

getopt

The getopt module is used to parse command-line options (typically passed in sys.argv).

getopt(args, options [, long_options])

Parses the command-line options supplied in the list args. options is a string of letters corresponding to the single-letter options that a program wants to recognize (for example, '-x'). If an option requires an argument, the option letter must be followed by a colon. If supplied, long_options is a list of strings corresponding to long option names. When supplied in args, these options are always preceded by a double hyphen (--), such as in '--exclude' (the leading -- is not supplied in long_options). Long option names requiring an argument should be followed by an equal sign (=). The function returns a list of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required