I want to implement a class in Python that returns an instance of another class when executed.
from Bmodule import B
class A:
def __new__(cls):
return B
And in the module Bmodule:
from Amodule import A
class B(A):
def __init__(self):
print("Class B was built")
But this is giving me an import error, probably due to the circular import. I know I could put both classes in a unique module, but I prefer to have them in separate ones. How can I fix it?
Thanks!!