3 ms·
This sounds very much like Python's __getattribute__ [0] method. Is there a difference I'm not understanding? [0] http://docs.python.org/reference/datamodel.ht
by hythloday 15y ago
This sounds very much like Python's __getattribute__ [0] method. Is there a difference I'm not understanding?
[0] http://docs.python.org/reference/datamodel.html#object.__getattribute__ http://docs.python.org/reference/datamodel.html#object.__get...
- sshumaker 15y agoI'm not that familiar with Python, but can you use __getattribute__ to provide methods as well? Using __index is the way you typically implement inheritance in Lua.
- timtadh 15y agoyes. >>> class A(object): ... def __getattribute__(self, key): ... try: return object.__getattribute__(self, key) ... except AttributeError: return lambda: 12 ... >>> a = A() >>> a.asdf <function <lambda> at 0x7fbb8fb6f848> >>> a.asdf() 12