Вы можете украсить функцию optparse.HelpFormatter.format_description:
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)
Таким образом, вы можете получить описание справки, которое выполняет такие вещи:
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."""
Работает для меня.:)