Created
October 30, 2014 13:24
-
-
Save kracekumar/8b66430e3170cafb0470 to your computer and use it in GitHub Desktop.
Handling missing class attributes
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 Foo(object): | |
lang = 'python' | |
def __getattr__(self, attr): | |
return 'No' | |
>>>Foo.lang | |
'python' | |
>>>Foo.os | |
AttributeError Traceback (most recent call last) | |
<ipython-input-29-cbf2d36846cc> in <module>() | |
----> 1 Foo.os | |
AttributeError: type object 'Foo' has no attribute 'os' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment