[Python-Dev] Changes to ConfigParser

Greg Stein gstein@lyra.org
Tue, 11 Jul 2000 02:08:18 -0700


On Tue, Jul 11, 2000 at 08:55:13AM +0300, Moshe Zadka wrote:
> On Mon, 10 Jul 2000, Eric S. Raymond wrote:
> > First, for completeness there ought to be remove_section and remove_option
> > methods (though forgetool does not yet use them).  I have documented these
> > as follows:
> > 
> > \begin{methoddesc}{remove_option}{section, option}
> > Remove the specified \var{option} from the specified \var{section}.
> > If the section does not exist, raise \exception{NoSectionError}.
> > If the option existed to be removed, return 1; otherwise return 0.
> 
> Ummm..encoding success/failure as return values is not usually a good
> idea. Why not raise KeyError if there is no such option in the section?

Eric is defining it as "okay" to remove a non-existent option. If you want
to know whether it was there, then check the return code. In most cases, you
just want to say "just make sure it isn't there any more."

IOW, I much prefer Eric's behavior spec over something that will generate an
exception.

> > \begin{methoddesc}{remove_section}{section}
> > Remove the specified \var{section} from the configuration.
> > If the section in fact existed, return 1.  Otherwise return 0.
> 
> Ditto. Raise a NoSectionError. IF someone wants to ignore the error, they
> can either check if it exists, or trap the error.

Same as above.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/