I have two files, one declaring a superclass which involves a method involving a subclass, and the other defining the subclass.
File1:
from file2 import subclass
class superclass:
def __init__(self):
"Stuff"
def method(self):
temp = subclass()
"Stuff"
File2:
from file1 import superclass
class subclass(superclass):
def __init__(self):
"Stuff"
When I run file1's code I get an error inside file2 that superclass is not defined. This is because I import file2 before defining the superclass.
However if I import file2 after defining superclass I get an error in file1 saying the subclass is not defined. This is because I use a subclass instance in the method.
One solution to this problem is to have both superclass and subclass declarations i