I always invoke optparse like this:
# specify constants
PROG_VERSION = "Version 0.1, January NN, 2004"
PROG_DESCRIPTION = """tool.py counts lines in each file.\n
Author: Tomi Mickelsson. """ + PROG_VERSION
# parse options and arguments
parser = OptionParser(PROG_USAGE,
option_list = option_list,
version = PROG_VERSION,
description = PROG_DESCRIPTION)
That is, I always specify the description info.
However, I'm not happy with the way description gets
usage: tool.py [-v] arg1 arg2
tool.py counts lines in each file. Author: Tomi
Mickelsson. Version 0.1, January NN, 2004
-h, --help show this help message and exit
My new lines are removed from the description field and
the result looks awful and arbitrary. I want to control
the new lines.
Could there be an option to insert "hard" new lines in
the description field? I wouldn't want to override
OptionParser.format_description function, I want an
easy solution that doesn't pollute my scripts; I use
optparse in all my scripts, it's a very useful module.
It seems that 1.5a2 works the same as earlier versions.
Log in to post a comment.