I searched everything and could not find a suitable search query for useful results. I will try to explain this with a simple example (which is tested).
Suppose I have a small Python user library that contains only the following private class and a public instance:
class _MyClass(object):
def __init__(self):
self.val = "Default"
my_instance = _MyClass()
Now I have two more python files ('file_a' and 'file_b') that will eventually import this instance from my library, as shown below.
Full code in the file 'file_a':
from my_lib import my_instance
my_instance.val = "File A was here!"
import file_b
file_b.check_val()
Full code in the file 'file_b':
from my_lib import my_instance
def check_val():
print "From 'file_b', my_instance.val is: {}".format(my_instance.val)
The result, if I only execute 'file_a' in a directory that also contains 'file_b' and 'my_lib', is:
From 'file_b', my_instance.val is: File A was here!
- , "file_b" , "file_a" ? , , 'file_a', ?
, , "MyClass" , "file_a" "file_b", , , - .