Created
May 31, 2016 19:08
-
-
Save jamesfe/c723c148dfb516405b616fd06a93b499 to your computer and use it in GitHub Desktop.
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
| # -*- coding: utf-8 -*- | |
| class X(object): | |
| things = { | |
| 'a': 1, | |
| 'b': 2, | |
| 'c': 3 | |
| } | |
| def __getattr__(self, attr): | |
| if attr in self.things: | |
| return self.things[attr] | |
| else: | |
| return super(X, self).__getattr__(attr) | |
| test_item = X() | |
| print test_item.a | |
| print test_item.b | |
| print X.a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment