[Python-Dev] dict.supplement() (was Re: list.shift())

Ka-Ping Yee ping@lfw.org
Mon, 20 Mar 2000 06:36:34 -0600 (CST)


On Mon, 20 Mar 2000, Peter Funk wrote:
> Consider another example, where arbitrary instance attributes should be
> specified as keyword arguments to the constructor:
> 
>   >>> class Example:
>   ...     _defaults = {'a': 1, 'b': 2}
>   ...     _config = _defaults
>   ...     def __init__(self, **kw):
>   ...         if kw:
>   ...             self._config = self._defaults.copy()
>   ...             self._config.update(kw)

Yes!  I do this all the time.  I wrote a user-interface module
to take care of exactly this kind of hassle when creating lots
of UI components.  When you're making UI, you can easily drown in
keyword arguments and default values if you're not careful.


-- ?!ng