Le vendredi 12 juin 2015 11:53:24 UTC-4, Paulo da Silva a écrit : > I would like to do something like this: > > class C: > def __init__(self,**parms): > ... > > c=C(f1=1,f2=None) > > I want to have, for the object > self.f1=1 > self.f2=None > > for an arbitrary number of parameters. > > What is the best way to achieve this? > > Thanks
in the __init__, simply do: self.__dict__.update(**parms) regards, gst. -- https://mail.python.org/mailman/listinfo/python-list