The first step in usingoptparse is to create an OptionParser instance:
parser = OptionParser(...)
The OptionParser constructor has no required arguments, but a number ofoptional keyword arguments. You should always pass them as keywordarguments, i.e. do not rely on the order in which the arguments aredeclared.
usage (default:"%prog [options]")%prog toos.path.basename(sys.argv[0]) (or toprog ifyou passed that keyword argument). To suppress a usage message,pass the special valueoptparse.SUPPRESS_USAGE.option_list (default:[])option_list are added after any options instandard_option_list (a class attribute that may be set byOptionParser subclasses), but before any version or help options.Deprecated; useadd_option() after creating the parser instead.option_class (default: optparse.Option)version (default:None)version,optparse automatically addsa version option with the single option string--version. Thesubstring"%prog" is expanded the same as forusage.conflict_handler (default:"error")description (default:None)usage, but beforethe list of options).formatter (default: a new IndentedHelpFormatter)add_help_option (default:True)"-h"and--help) to the parser.prog"%prog" inusage andversion instead ofos.path.basename(sys.argv[0]).