You can decorate optparse.HelpFormatter.format_description function:
from optparse import HelpFormatter as fmt def decorate(fn): def wrapped(self=None, desc=""): return '\n'.join( [ fn(self, s).rstrip() for s in desc.split('\n') ] ) return wrapped fmt.format_description = decorate(fmt.format_description)
This way you can get a help description that does the following:
my_desc = """This is some text that wraps to some more stuff.\n \n And this is a new paragraph.\n \n This line comes before\n this line but not in a different paragraph."""
Works for me. :)
source share