[Python-Dev] Re: [Patches] [1.6] dictionary objects: new method 'supplement'

Peter Funk pf@artcom-gmbh.de
Mon, 3 Apr 2000 13:12:25 +0200 (MEST)


Hi!

> Greg Stein wrote:
> > I don't recall the termination of the discussion, but I don't know that
> > consensus was ever reached.
> 
Fredrik Lundh:
> iirc, Ping liked it, but I'm not sure anybody else contributed
> much to that thread...

That was my impression: It is hard to guess what you guys 
think from mere silence. ;-)

> (and to neutralize Ping, just let me say that I don't like it :-)
> 
> > Personally, I find this of little value over the similar (not exact) code:
> > 
> > def supplement(dict, extra):
[...]
> > Another view: why keep adding methods to service all possible needs?
> 
> exactly.

A agree that we should avoid adding new methods all over the place.  
But IMO this is an exception:  I proposed it for the sake of symmetry
with 'update'.  From my POV 'supplement' relates to 'update' as '+'
relates to '-'.  YMMV and I will not be angry, if this idea will be 
finally rejected.  But it would have saved me an hour or two
of coding and testing time if you had expressed your opinions a 
little bit earlier. ;-)  But I know: you are all busy.  To get an
impression of possible uses for supplement,  I sketch some code here:

	class MysticMegaWidget(MyMegaWidget):
	    _config = {
	        horizontal_elasticity = 1000,
		vertical_elasticity = 10,
		mentalplex_fg_color = "#FF0000",
		mentalplex_bg_color = "#0000FF",
                font = "Times",
	    }
	    def __init__(self, *args, **kw):
	        if kw:
		    self._config = kw
		    self._config.supplement(self.__class__._config)
		....

Of course this can also be implemented using 'copy' and 'update'.  
It's only slightly more complicated.  But you can also emulate any boolean
operation using only NAND.  Nevertheless any serious programming 
language contains at least OR, AND, NOT and possibly XOR.

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)