Created
August 8, 2018 05:47
-
-
Save zhusimaji/df879dd537a6729b6201f456e2c08b71 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 Proxy: | |
def __init__(self, obj): | |
self._obj = obj | |
def __getattr__(self, item): | |
#这里的毛病 | |
return getattr(self._obj, item) | |
class Spam: | |
def __init__(self, x): | |
self.x = x | |
def bar(self, y): | |
print('Spam.bar:', self.x, y) | |
if __name__ == "__main__": | |
spam = Spam(10.05) | |
proxy = Proxy(spam) | |
print(proxy.x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment