e.g. f1.py (simplified):
...
class TestClass:
x = 0
...
and f2.py :
from f1 import *
tc = TestClass()
tc.x = 73
and f3.py :
from f1 import *
...
print(tc.x)
...
Of course this is wrong, but how to do it right? Well, I simply need access to data and functions in the same instance of a class from different files, comparable to e.g. 'extern' in C. Generating a new instance in every file will generate different variables, is therefore not applicable. Thanks for help.
f3.pywhich wants to accesstc.x?tc = TestClass()at the bottom off1.pyand simply import that in the other files, rather than the class itself? (Unfortunately Python does not allow you to choose not to export the class, as many other languages do.)tc = TestClass()in f1.py and import f1 to other files where needed. Thanks for the fast help