pre-PEP generic objects

François Pinard pinard at iro.umontreal.ca
Tue Nov 30 17:52:33 EST 2004


[Scott David Daniels]

> You can simplify this:
> class Hash(object):
>     def __init__(self, **kwargs):
>         for key,value in kwargs.items():
>             setattr(self, key, value)

Might it be:

    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the Python-list mailing list