Skip to content

Instantly share code, notes, and snippets.

Created April 19, 2013 21:16
Show Gist options
  • Save anonymous/5423293 to your computer and use it in GitHub Desktop.
Save anonymous/5423293 to your computer and use it in GitHub Desktop.
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)
@shakkhar
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment