How to output newline or carriage return with optparse
python.list at tim.thechases.com
Thu Nov 8 17:46:49 CET 2007
> I'm trying to implement some simple command line options.
> Some of the 'help' sections are long and I would like to
> control line breaks. How do you do this?
I had this problem earlier and solved it here:
thanks to a little guidance from Ben Finney on where to look.
It came up again last month here:
which should solve the problem for you.
ASIDE: I've started refactoring this bit out in my local
source...how would I go about contributing it back to the Python
code-base? I didn't get any feedback from posting to the Optik
site. My refactor basically takes an optional pre-processing
function to parse your string into the output that gets passed to
textwrap.wrap() and textwrap.fill(), defaulting to the old
behavior, but offering a function for splitting it into
paragraphs based on newlines.
More information about the Python-list