Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Python's optparse display the default value of an option?

Is there a way to make Python's optparse print the default value of an option or flag when showing the help with --help?

like image 589
pupeno Avatar asked Aug 10 '09 11:08

pupeno


1 Answers

Try using the %default string placeholder:

# This example taken from http://docs.python.org/library/optparse.html#generating-help parser.add_option("-m", "--mode",                   default="intermediate",                   help="interaction mode: novice, intermediate, "                        "or expert [default: %default]") 
like image 154
Jarret Hardie Avatar answered Oct 09 '22 03:10

Jarret Hardie