On Wed, Apr 26, 2017 at 08:02:39AM -0400, [email protected] wrote:
> > self.__dict__.update(kwargs)
>
> Touching __dict__ feels dirty to me.
Indeed. The right way is:
vars(self).update(kwargs)
although that doesn't work if self is written to use __slots__ instead
of having a __dict__.
You can even (almost) get this same effect and still have named
parameters:
def __init__(self, fe, fi, fo, fum, spam, eggs, foo, bar, baz):
vars(self).update(locals())
del self.self
--
Steve
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/