Created
April 19, 2013 21:16
-
-
Save anonymous/5423293 to your computer and use it in GitHub Desktop.
This file contains 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
class Dp: | |
my_attr = 'foo' | |
funs = [] | |
for attr in ('my_attr', 'doesnt_exist', 'my_attr'): | |
funs.append(lambda obj: getattr(dp, attr)) | |
dp = Dp() | |
for fun in funs: | |
print fun(dp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/shahriman/5423475