Re: Optparse and help formatting?
- From: Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 13:19:06 -0000
On Sun, 30 Sep 2007 07:37:10 -0500, Tim Chase wrote:
def format_option(self, option):[snip]
# The help for each option consists of two parts:
# * the opt strings and metavars
Tim, I notice you're using lots of # lines as comments to describe the
function. Perhaps you should consider using docstrings instead.
Pardon me if I'm telling you what you already know...
A docstring is a string that immediately follows a class, function or
method declaration, or at the beginning of a module:
def parrot():
"This is a doc string."
s = "this is not a docstring"
The advantage of docstrings is that unlike # comments, they aren't
discarded at compile time, and can be accessed by the caller:
'This is a doc string'parrot.__doc__
This is especially useful in the interactive interpreter, where
help(object) will grab the docstring and format it nicely on screen.
--
Steven.
.
- Follow-Ups:
- Re: Optparse and help formatting?
- From: Tim Chase
- Re: Optparse and help formatting?
- References:
- Optparse and help formatting?
- From: Tim Chase
- Re: Optparse and help formatting?
- From: Ben Finney
- Re: Optparse and help formatting?
- From: Tim Chase
- Optparse and help formatting?
- Prev by Date: Re: Optparse and help formatting?
- Next by Date: Re: Can you please give me some advice?
- Previous by thread: Re: Optparse and help formatting?
- Next by thread: Re: Optparse and help formatting?
- Index(es):
Relevant Pages
|