[Tutor] using **kwargs in __init__() as attributes
Alan Gauld
alan.gauld at btinternet.com
Mon Oct 1 20:04:22 CEST 2007
"János Juhász" <janos.juhasz at VELUX.com> wrote
> class ADUser:
> def __init__(self, **kwargs):
> for key in kwargs.keys():
> self.key = kwargs[k]
>
> a = ADUser(name='papa')
>
>
> It isn't working :(
Try using setattr instead of self.key assignment.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list