I want to do something like the following
class A:
def static_method_A():
print "hello"
def main(param=A):
param.static_method_A()
I want this to be equivalent to A.static_method(). Is this possible?
Sure. Classes are first-class objects in Python.
Although, in your example, you should use the @classmethod (class object as initial argument) or @staticmethod (no initial argument) decorator for your method.
You should be able to do the following (note the @staticmethod decorator):
class A:
@staticmethod
def static_method_A():
print "hello"
def main(param=A):
param.static_method_A()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With