How to dynamically invoke a staticmethod without creating an instance object

34 views Asked by At

Code similar to this is typically used to dynamically create a class object and call an instance method, but how can I dynamically call a @staticmethod in a class without constructing an instance? This post is useful but doesn't show invocation: How to list all staticmethods of a python class

module = __import__('MyClass')
my_class = getattr(module, 'MyClass')    # this invokes constructor
result = my_class().my_static_method()
0

There are 0 answers