Consider this class containing methods without a self argument:
class C:
def foo(a,b):
# function does something
# It is not an instance method (i.e. no 'self' argument)
def bar(self):
# function has to call foo() of the same class
foo('hello', 'world')
The above code errors when non-instance method foo() is called within bar(). Somehow the name 'foo' is not recognized even though it's a method within the same class body. If it were an instance method, it could be called using self.foo() but here that's not the case.
What's the best way to invoke foo() for the above example?
# 1 Like this?
C.foo('hello', 'world')
# 2 Like this?
self.__class__.foo('hello', 'world')
# Something else?