Staging: this is not the live site, pydocs.org.
Command-line interface libraries optparse A powerful, extensible, and easy-to-use option parser.
Simple usage example:
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help="don't print status messages to stdout")
(options, args) = parser.parse_args() © Python Software Foundation. PSF License Version 2 · Official docs ↗
Symbols in optparse b BadOptionError Raised if an invalid option is seen on the command line. o Option Instance attributes: _short_opts : [string] _long_opts : [string] OptionError Raised if an Option instance is created with invalid or inconsistent arguments. OptionParser Class attributes: standard_option_list : [Option] list of standard options that will be accepted by all instances of this parser class (intended to be overridden by subclasses). OptionValueError Raised if an invalid option value is encountered on the command line. v Values An object holding parsed argument names and values as attributes.
Python docs © Python Software Foundation · Examples CC0 ·
Source on GitHub · Not affiliated with the PSF