Say I have two files, file1.py and file2.py. In file1.py, I define two classes, one inherits from the other:
file1.py:
class Class1:
def __init__(self):
pass
def func1(self):
return "Hello world!"
class Class2(Class1):
def __init__(self):
pass
def func2(self):
return self.func1()
So now I'm able to call func1()
and func2()
from Class2
.
file2.py:
import file1
class Class3(file1.Class2):
def __init__(self):
pass
Question: How can I change func1()
from Class1
in file2.py, so that func2()
in Class2
returns the same as func1()
?
So not like this:
class Class3(file1.Class2):
...
def func1(self):
return "Another string"