set_defaults() vs set_default()

Greg Ward <[email protected]> Fri, 18 Mar 2005 20:38:21 -0500
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
For reasons that I can no longer remember, Optik has two methods for
setting default values for option destinations:

  parser.set_defaults(verbose=1,
                      mode="advanced",
                      clobber=False)

and

  parser.set_default("verbose", 1)
  parser.set_default("mode", "advanced")
  parser.set_default("clobber", False)

I have never documented set_default(), only set_defaults().  So only
people who grovel around in the code would know about set_default(), and
only people who enjoy using a more awkward, less-convenient interface
would even bother with it.  The only tiny advantage to set_default() is
that it could be more useful when your option destinations and their
default values are data-driven rather than hard-coded.  And that
objection is pretty easy to counter:

  parser.set_defaults(**defaults)

Would anyone care if set_default() disappeared in the next major Optik
release (whether that's 1.6 or 2.0)?

        Greg
-- 
Greg Ward <[email protected]>                         http://www.gerg.ca/
Clarke's Law:
Any sufficiently advanced technology is indistinguishable from magic.


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click