Skip to content

Instantly share code, notes, and snippets.

@rcoup
Last active December 18, 2015 03:19
Show Gist options
  • Save rcoup/5717772 to your computer and use it in GitHub Desktop.
Save rcoup/5717772 to your computer and use it in GitHub Desktop.
__getattr__ plus @Property is NOT INTUITIVE
class Test(object):
@property
def x(self):
print "property-x"
return 7
def y(self):
return 8
a = 9
def __getattr__(self, name):
print "getattr:", name
#if isinstance(getattr(self.__class__, name, None), property):
# return super(Test, self).__getattr__(name)
return 1
@rcoup
Copy link
Author

rcoup commented Jun 5, 2013

>>> t = Test()
>>> t.y()
8
>>> t.a
9
>>> t.x
getattr: x
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment