Getting a dictionary from an object

Thanos Tsouanas thanos at sians.org
Mon Jul 25 16:48:46 EDT 2005


On Sun, Jul 24, 2005 at 02:14:15PM -0600, Steven Bethard wrote:
> 
> How about something like:
>      dict((name, getattr(obj, name)) for name in dir(obj))

Pretty!!!

> Looks like this will get instance attributes, class attributes and 
> properties just fine.

But not SQLObject's objects...
Any idea why? (Getting attribute errors, it seems that these
"attributoids" are not listed in dir(obj), so i have to use my ugly
dictobj class.. :(

-- 
Thanos Tsouanas          .: My Music: http://www.thanostsouanas.com/
http://thanos.sians.org/ .: Sians Music: http://www.sians.org/



More information about the Python-list mailing list