Created
August 28, 2015 18:51
-
-
Save joferkington/a97452653017f774ae4b to your computer and use it in GitHub Desktop.
Lovely dynamic typing
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
import random | |
class BadIdea(object): | |
def __getattr__(self, key): | |
return random.randint(0, 1000) | |
def __setattr__(self, key, value): | |
pass | |
x = BadIdea() | |
print x.bar | |
x.bar = 10 | |
print x.bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment