diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2008-01-19 21:00:38 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2008-01-19 21:00:38 (GMT) |
commit | 8b506e7a2d4e8cb6ffd6b7f2845e45aa92daa4d4 (patch) | |
tree | 191a12a1e59af5476c1a77d6bd8eaa0a96d471d2 /Doc | |
parent | b9ba07540035004abdc3a29af0e6b43d7f881659 (diff) | |
download | cpython-8b506e7a2d4e8cb6ffd6b7f2845e45aa92daa4d4.zip cpython-8b506e7a2d4e8cb6ffd6b7f2845e45aa92daa4d4.tar.gz cpython-8b506e7a2d4e8cb6ffd6b7f2845e45aa92daa4d4.tar.bz2 |
Bug 1296: restore text describing OptionGroup
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/optparse.rst | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst index e193eb8..e5937b7 100644 --- a/Doc/library/optparse.rst +++ b/Doc/library/optparse.rst @@ -539,6 +539,35 @@ help message: default value. If an option has no default value (or the default value is ``None``), ``%default`` expands to ``none``. +When dealing with many options, it is convenient to group these +options for better help output. An :class:`OptionParser` can contain +several option groups, each of which can contain several options. + +Continuing with the parser defined above, adding an +:class:`OptionGroup` to a parser is easy:: + + group = OptionGroup(parser, "Dangerous Options", + "Caution: use these options at your own risk. " + "It is believed that some of them bite.") + group.add_option("-g", action="store_true", help="Group option.") + parser.add_option_group(group) + +This would result in the following help output:: + + usage: [options] arg1 arg2 + + options: + -h, --help show this help message and exit + -v, --verbose make lots of noise [default] + -q, --quiet be vewwy quiet (I'm hunting wabbits) + -fFILE, --file=FILE write output to FILE + -mMODE, --mode=MODE interaction mode: one of 'novice', 'intermediate' + [default], 'expert' + + Dangerous Options: + Caution: use of these options is at your own risk. It is believed that + some of them bite. + -g Group option. .. _optparse-printing-version-string: |