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 ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.