
April 26, 2017
5:46 p.m.
On 2017-04-26 04:12, Brice PARENT wrote:
Why not simply do this :
class MyClass: def _set_multiple(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value)
def __init__(self, a, b, c): self._set_multiple(a=a, b=b, c=c)
If the goal is to not have to type out argument names three times (in DRY fashion), this doesn't quite fit the bill. -Mike