from dict to member vars...?

George Yoshida ml at
Thu Oct 14 20:37:36 CEST 2004

Christopher J. Bottaro wrote:

> Lets say I have a class instance with the following member vars:  var1, x,
> size.  Now lets say I have dict with the following keys:  var1, x, size. 
> Is there an easy way to *automatically* assign all the values in the dict
> to corresponding (member) vars of the same name as the dict keys?
> Thanks for the help.

If class is a new style class, you can do it this way:


-- george

More information about the Python-list mailing list