Skip to content

Instantly share code, notes, and snippets.

@akaptur
Created August 20, 2012 22:01
Show Gist options
  • Save akaptur/3408317 to your computer and use it in GitHub Desktop.
Save akaptur/3408317 to your computer and use it in GitHub Desktop.
A way to get the attributes of an object without using getattr
for attr in dir(obj):
code = 'obj.' + attr
print attr, eval(code)
for attr in [x for x in dir(obj) if not callable(getattr(obj, x))]:
code = 'obj.' + attr
print attr, eval(code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment