You can't just use file like an object in python, you must import the class to use it in your file1 :
from .file2 import mytest
After that you can use it in your file1
def f0():
mytest.f1("5")
But it will throw an error because in your class constructor, you call f2() before f1() so n isn't instantiated.
Traceback (most recent call last):
File "C:\Dev\tmp\file1.py", line 1, in <module>
from file2 import mytest
File "C:\Dev\tmp\file2.py", line 1, in <module>
class mytest:
File "C:\Dev\tmp\file2.py", line 10, in mytest
f2()
File "C:\Dev\tmp\file2.py", line 8, in f2
print("test f2 : " + n)
^
NameError: name 'n' is not defined
Btw you shouldn't call functions in your class constructor.
I doesn't understand why you need global variable, can you explain it please ?