Re: [PATCH] %default keyword expansion
David Goodger <[email protected]> Thu, 01 Apr 2004 08:37:27 -0500
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
Greg Ward wrote:
> -- surely there's an easier way. Anyone?
Why not let Python do the work? Instead of "%default", use
"%(default)s", and do this:
def _expand_default (self, help_text, default):
return help_text % {'default': default}
This mechanism could easily be expanded in the future to other
parameters. It also allows for flexible formatting (e.g.,
"%(default).2f" with a float default).
Perhaps %prog should be redefined (or, additionally defined) in
this way also.
--
David Goodger http://python.net/~goodger
For hire: http://python.net/~goodger/cv
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click