Python doesn't use separate spaces for callable and non-callable objects: a name is a name is a name. s.x
, by Python rules, must refer to exactly the same object, whether you're going to call it or not. Another way of putting it: assuming that _aux
is a name not otherwise used,
_aux = self.x
_aux()
and
self.x()
must have absolutely identical semantics in Python, the fact that in the former the intermediate value self.x
is being bound to a name and called later notwithstanding.
Having single, "unified" namespaces for callables and non-callables has a huge number of advantages -- it makes name-lookup rules (for each of bare and qualified names) enormously simpler, for example, by decoupling them totally from the purpose to which the name being looked up is going to be put (be it immediately after the lookup's result, or later still), and also from the type (callable or non-callable) of whatever object turns up to be first referenced according to the lookup rules.
Especially considering how many different callable types Python has (functions, classes, instances of classes which define __call__
, special types such as staticmethod
and classmethod
, ...!-), any other rule could only lead to total chaos. (Note also, for example, that even C++, a language which definitely is not afraid by complexity but which also lets class-instances be callable [[if the class overloads operator()
]], uses a similar unified-namespace rule -- again, discriminating between callables and non-callables would be a totally unwarranted nightmare, were the rules any different in this regard!-).