class A(object): def __init__(self, val): self.val = A.plus_one(val) @staticmethod def plus_one(val): return val + 1
We can define a static method in a class and use it in any places. My question is, why do we have to namespace the static method even when we use this static method within this class, that is, to add A.
before the method name.
My idea is, can we simply change the mechanism so that the static method name within the class does not have to be namespaces as in: (although Python does not support it now):
class A(object): def __init__(self, val): self.val = plus_one(val) @staticmethod def plus_one(val): return val + 1
My intuition is, since we are calling from within the class, the priority of class members should be higher than global functions, and thus there won't be any ambiguity. Why does Python force us to namespace it?