Re: Optparse and help formatting?
- From: Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 14:15:09 +1000
Tim Chase <python.list@xxxxxxxxxxxxxxxxx> writes:
I've been learning the ropes of the optparse module and have been
having some trouble getting the help to format the way I want.
A quick perusal of the 'optparse.py' code shows me this:
========
[...]
class OptionParser([...]):
def __init__([...],
formatter=None,
[...]):
[...]
if formatter is None:
formatter = IndentedHelpFormatter()
[...]
========
So, the OptionParser init method accepts the help formatter as the
'formatter' argument, defaulting to a new instance of
IndentedHelpFormatter.
Presumably, it's a matter of subclassing 'optparse.HelpFormatter' and
overriding the behaviour you want to change, then passing an instance
of your new class as the 'formatter' argument to the 'OptionParser()'
invocation.
--
\ "Members of the general public commonly find copyright rules |
`\ implausible, and simply disbelieve them." -- Jessica Litman, |
_o__) _Digital Copyright_ |
Ben Finney
.
- Follow-Ups:
- Re: Optparse and help formatting?
- From: Tim Chase
- Re: Optparse and help formatting?
- References:
- Optparse and help formatting?
- From: Tim Chase
- Optparse and help formatting?
- Prev by Date: Re: question about for cycle
- Next by Date: New to python
- Previous by thread: Optparse and help formatting?
- Next by thread: Re: Optparse and help formatting?
- Index(es):