How to output newline or carriage return with optparse
Tim Chase
python.list at tim.thechases.com
Thu Nov 8 11:46:49 EST 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:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/6df6e6b541a15bc2/09f28e26af0699b1
thanks to a little guidance from Ben Finney on where to look.
It came up again last month here:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/e72deee779d9989b/
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.
-tkc
More information about the Python-list
mailing list