On Sat, Aug 29, 2009 at 6:30 PM, Damon Timm<[email protected]> wrote:
> Hey! I am a newbie too but it works for me:
>
>>>> class Test(object):
> ... def __init__(self,dict):
> ... for key in dict:
> ... self.__setattr__(key,dict[key])
Use the setattr() builtin:
setattr(self, key, dict[key]}
or just
def __init__(self, d):
self.__dict__.update(d)
BTW don't use dict as the name of a variable, it shadows the built-in
of the same name.
Kent
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor