Is there any way to determine the difference between a method and an attribute call using __getattr__?
I.e. in:
class Bar(object):
def __getattr__(self, name):
if THIS_IS_A_METHOD_CALL:
# Handle method call
def method(**kwargs):
return 'foo'
return method
else:
# Handle attribute call
return 'bar'
foo=Bar()
print(foo.test_method()) # foo
print(foo.test_attribute) # bar
The methods are not local so it's not possible to determine it using getattr/callable. I also understand that methods are attributes, and that there might not be a solution. Just hoping there is one.
list.reverse
be sufficient for "if THIS_IS_A_METHOD_CALL"... or is "list.reverse()" required for a method call – Kneeland