MCPcopy Index your code
hub / github.com/python/cpython / OptionParser

Class OptionParser

Lib/optparse.py:1096–1637  ·  view source on GitHub ↗

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). Instance attributes: usage : string a usage string for your program. Before

Source from the content-addressed store, hash-verified

1094
1095
1096class OptionParser (OptionContainer):
1097
1098 """
1099 Class attributes:
1100 standard_option_list : [Option]
1101 list of standard options that will be accepted by all instances
1102 of this parser class (intended to be overridden by subclasses).
1103
1104 Instance attributes:
1105 usage : string
1106 a usage string for your program. Before it is displayed
1107 to the user, "%prog" will be expanded to the name of
1108 your program (self.prog or os.path.basename(sys.argv[0])).
1109 prog : string
1110 the name of the current program (to override
1111 os.path.basename(sys.argv[0])).
1112 description : string
1113 A paragraph of text giving a brief overview of your program.
1114 optparse reformats this paragraph to fit the current terminal
1115 width and prints it when the user requests help (after usage,
1116 but before the list of options).
1117 epilog : string
1118 paragraph of help text to print after option help
1119
1120 option_groups : [OptionGroup]
1121 list of option groups in this parser (option groups are
1122 irrelevant for parsing the command-line, but very useful
1123 for generating help)
1124
1125 allow_interspersed_args : bool = true
1126 if true, positional arguments may be interspersed with options.
1127 Assuming -a and -b each take a single argument, the command-line
1128 -ablah foo bar -bboo baz
1129 will be interpreted the same as
1130 -ablah -bboo -- foo bar baz
1131 If this flag were false, that command line would be interpreted as
1132 -ablah -- foo bar -bboo baz
1133 -- ie. we stop processing options as soon as we see the first
1134 non-option argument. (This is the tradition followed by
1135 Python's getopt module, Perl's Getopt::Std, and other argument-
1136 parsing libraries, but it is generally annoying to users.)
1137
1138 process_default_values : bool = true
1139 if true, option default values are processed similarly to option
1140 values from the command line: that is, they are passed to the
1141 type-checking function for the option's type (as long as the
1142 default value is a string). (This really only matters if you
1143 have defined custom types; see SF bug #955889.) Set it to false
1144 to restore the behaviour of Optik 1.4.1 and earlier.
1145
1146 rargs : [string]
1147 the argument list currently being parsed. Only set when
1148 parse_args() is active, and continually trimmed down as
1149 we consume arguments. Mainly there for the benefit of
1150 callback options.
1151 largs : [string]
1152 the list of leftover arguments that we have skipped while
1153 parsing options. If allow_interspersed_args is false, this

Callers 15

mainFunction · 0.90
mainFunction · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
test_refleakMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
test_default_prognameMethod · 0.90
test_custom_prognameMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 15

setUpMethod · 0.72
setUpMethod · 0.72
test_refleakMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
test_default_prognameMethod · 0.72
test_custom_prognameMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…