object attributes from a dictionary

John Lenton jlenton at gmail.com
Wed Jul 14 22:08:02 CEST 2004

On Wed, 14 Jul 2004 11:39:07 -0400, Darren Dale <dd55 at cornell.edu> wrote:
> I see. I wasnt clear when I asked my original question. A dictionary is
> already an object. I wanted to take a dictionary and by creating a new
> object, turn the key/value pairs into object attributes.
> Using Peters class definition,
> larva={'a':1,'b':2}
> moth=pupa(larva)
> vars(moth) --> a dictionary listing attribute/value pairs.
> Using your definition, John, vars(moth) yields an empty dictionary.
> Thats why I didnt think it was working, but you are right. It works,
> just not the way I looking for.

you hadn't mentioned vars :)

John Lenton (jlenton at gmail.com) -- Random fortune:
bash: fortune: command not found

More information about the Python-list mailing list