Error in optparse documentation

Shatadal gshatadal at rediffmail.com
Sun May 27 17:54:42 EDT 2007


In the python documentation section 14.3.2.6 (http://docs.python.org/
lib/optparse-generating-help.html) in the last line it is written

"options that have a default value can include %default in the help
string--optparse will replace it with str() of the option's default
value. If an option has no default value (or the default value is
None), %default expands to none."

However this is true only for python 2.4 and newer and not for older
versions. Though the documentation for optparse (section 14.3,
http://docs.python.org/lib/module-optparse.html) says that the module
is new for python 2.3, in this version a help string (default value =
intermediate) e.g.

help="interaction mode: novice, intermediate, or expert [default:
%default]"

prints

interaction mode: novice, intermediate, or expert [default: %default]

and not:

interaction mode: novice, intermediate, or expert [default:
intermediate]

Only in python 2.4 and newer do you see the help string print as

interaction mode: novice, intermediate, or expert [default:
intermediate]

I think the documentation should be modified so that it is made clear
that %default in the help string behaves as is claimed only in version
2.4 and higher.


O.S. used is RHEL 9




More information about the Python-list mailing list