Created
August 20, 2012 22:01
-
-
Save akaptur/3408317 to your computer and use it in GitHub Desktop.
A way to get the attributes of an object without using getattr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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