Formated String in optparse
Peter Otten
__peter__ at web.de
Thu Mar 31 05:46:52 EST 2005
MyHaz wrote:
> If you haven't looked into it, you may like the way class
> OptionParser() makes the help text for you.
What do you mean?
To clarify: OptionParser's help message in the default format is
"""
usage: discard_newline.py [options]
einsamer nie als im august erfuellungsstunde im gelaende die roten und die
goldenen braende doch wo ist deiner gaerten lust
options:
-h, --help show this help message and exit
-x EXAMPLE, --example=EXAMPLE
die seen hell die himmel weich die aecker rein und
glaenzen leise doch wo sind sieg und siegsbeweise
aus
dem von dir vertretenen reich wo alles sich durch
glueck
"""
whereas that same OptionParser with the tweaked optparse.textwrap (my
TextWrapper instance replacing the textwrap module from the standard
library) will output
"""
usage: preserve_newline.py [options]
einsamer nie als im august
erfuellungsstunde im gelaende
die roten und die goldenen braende
doch wo ist deiner gaerten lust
options:
-h, --help show this help message and exit
-x EXAMPLE, --example=EXAMPLE
die seen hell die himmel weich
die aecker rein und glaenzen leise
doch wo sind sieg und siegsbeweise aus dem von dir
vertretenen reich wo alles sich durch glueck
"""
I guess that both poets in residence and limmerickistas will prefer the
latter form :-)
Peter
More information about the Python-list
mailing list