optionparse: how to add a line break to the help text
gelonida at gmail.com
Sun Sep 11 16:30:07 CEST 2011
On 09/11/2011 07:20 AM, Ben Finney wrote:
> Gelonida N <gelonida at gmail.com> writes:
>> Considering, that you posted the snippet in 2007 and this is very
>> probably a reocurring problem for any slighty more complicated help
>> text it is really a pity, that it did not become of part of the
>> standard optparse library :-(
> The ‘optparse’ library is, as the online documentation shows
> <URL:http://docs.python.org/library/optparse.html>, deprecated for new
> The optparse module is deprecated and will not be developed further;
> development will continue with the argparse module.
This explains the reluctance to fix optparse. In 2007 however python 2.7
wasn't really that common though
> The standard library ‘argparse’ module has a feature you might prefer
Most of my code has to run on python 2.5 / 2.6.
I just checked, that argparse can be installed (pip install argparse)
(didn't check functionality though) for python 2.5 / 2.6
So depending on the situation I had to decide whether I oblige users of
my scripts to install argparse or whether I stick with optparse and
just add Tim's custom formatter.
Probably I'll go for optparse and Tim's custom formatter for tiny
scripts with no dependencies except standard libraries and
for argparse for new bigger projects with external module dependencies.
More information about the Python-list