How can I get a reference to the class in a static method?
I have following code:
class A:
def __init__(self, *args):
...
@staticmethod
def load_from_file(file):
args = load_args_from_file(file)
return A(*args)
class B(A):
...
b = B.load_from_file("file.txt")
But I want to B.load_from_file return object of type B, not A. I know if load_from_file wouldn't be a static method I could do
def load_from_file(self, file):
args = load_args_from_file(file)
return type(self)__init__(*args)