Getting a dictionary from an object

Steven Bethard steven.bethard at gmail.com
Sun Jul 24 02:59:43 CEST 2005


Thanos Tsouanas wrote:
> I would like to have a quick way to create dicts from object, so that a
> call to foo['bar'] would return obj.bar.
> 
> The following works, but I would prefer to use a built-in way if one
> exists.  Is there one?

Maybe I'm not understanding your problem, but have you looked at the 
builtin "vars()"?

STeVe



More information about the Python-list mailing list