class Foo(object):
    bar = 'hello'
baz = 'world'
f = Foo()
[name for name in dir(f) if not name.startswith('__')]
dict((name, getattr(f, name)) for name in dir(f) if not name.startswith('__'))
Python dictionary from an object's fields