Re: Re: [PATCH] %default keyword expansion
Greg Ward <[email protected]> Tue, 18 May 2004 08:49:58 -0400
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
On 17 May 2004, John Belmonte said:
> Just last week I used custom option types for the first time, and was
> thinking "I guess that %default expansion thing I proposed needs to be
> tossed out the window". (See attached example.)
>
> Actually, %default expansion is innocent here. The problem is that
> defaults are not run through the option's checker/converter. For types
> which are converted, why shouldn't the programmer be able to give the
> same value for a default that the user would put on the command line,
> rather than have to mentally convert to a normalized value? I've run
> into the same issue with ZConfig, and it seems like a design error to
> me. The %default expansion just makes the issue more obvious.
At first glance, you're absolutely right -- default values should be
treated like values from the command line. Lets the developer supply a
default that a) looks good in the help and b) maps onto the user's
mental model for that option, which hopefully is the same as the
developer's mental model.
> I propose that Option and add_option take a new keyword "nice_default".
> Nice defaults are passed through the option checker just as if they
> were passed on the command line. In this case, %default will expand to
> the pre-checked value.
Possibly simpler: always pass default values through the type-checking
and -conversion code. For built-in types, eg. string and int, this is
no problem: int("37") == int(37) == 37. It might be problematic for
people who write custom types though -- eg. you'd have to make sure that
your _check_duration() accepts both "5m" and 300.
I'll create a bug report on SF to track this. It'll have to queue up
behind several other pending bugs and features.
Greg
--
Greg Ward <[email protected]> http://www.gerg.ca/
When you make your mark in the world, watch out for guys with erasers.
-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click