set_defaults(dest=valuedest=valuesets the default values of particular option destinations you simply supply keyword arguments that specify the destinations you wish to set the name of the keyword arguments should match the names specified using the dest parameter in add_option()described earlier set_usage(usagechanges the usage string displayed in text produced by the --help option example foo py import optparse optparse optionparser( simple optionwith no arguments add_option("- "action="store_true"dest="tracing"an option that accepts string argument add_option("- ""--outfile"action="store"type="string"dest="outfile"an option requires an integer argument add_option("- ""--debuglevel"action="store"type="int"dest="debug"an option with few choices add_option("--speed"action="store"type="choice"dest="speed"choices=["slow","fast","ludicrous"]an option taking multiple arguments add_option("--coord"action="store"type="int"dest="coord"nargs= set of options that control common destination add_option("--novice"action="store_const"const="novice"dest="mode" add_option("--guru"action="store_const"const="guru"dest="mode"set default values for the various option destinations set_defaults(tracing=falsedebug= speed="fast"coord=( , )mode="novice"parse the arguments optargs parse_args(print option values print "tracing :"opt tracing print "outfile :"opt outfile print "debug :"opt debug print "speed :"opt speed print "coord :"opt coord print "mode :"opt mode print remaining arguments print "args :"args lib fl ff