Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Created October 30, 2014 13:24
Show Gist options
  • Save kracekumar/8b66430e3170cafb0470 to your computer and use it in GitHub Desktop.
Save kracekumar/8b66430e3170cafb0470 to your computer and use it in GitHub Desktop.
Handling missing class attributes
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