On Tue, 30 Nov 2004 17:52:33 -0500, =?iso-8859-1?Q?Fran=E7ois?= Pinard <[EMAIL 
PROTECTED]> wrote:
>[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)
> 

  One thing I notice with both of these versions:

    >>> Hash(self=10)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    TypeError: __init__() got multiple values for keyword argument 'self'

  __self would be better; a version that doesn't preclude the use of any key 
would be best.

  Jp
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to