Do you know if there is a built-in function to build a dictionary from an arbitrary object? I’d like to do something like this:

>>> class Foo:
...     bar="hello"
...     baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }

NOTE: It should not include methods. Only fields.

16 Answers
16

Leave a Reply

Your email address will not be published. Required fields are marked *