Suppose you want to call a method foo
on object bar
, but somehow while typing the method invocation you intuitively treated foo
as a property and you typed bar.foo
instead of bar.foo()
(with parenthesis). Now, both are syntactically correct, so no error is raised, but semantically very different. It happened to me several times already (my experience in Ruby makes it even worse) and caused me dearly in terms of long and confusing debugging sessions.
Is there a way to make Python interpreter print a warning in such cases - whenever you access an attribute which is callable, but you haven't actually called it?
For the record - I thought about overriding __getattribute__
but it's messy and ultimately won't achieve the goal since function invocation via ()
happens after __getattribute__
has returned.