In your code, you are trying to use a global variable defined in one file in another file, but you are not using the global keyword in the correct way. In Python, you must use the global keyword to declare that a variable is global, and you must use it in the same scope where you want to use the global variable.
In your code, you are defining the string_global variable in file1.py as a global variable, but you are not using the global keyword in the correct way in file2.py and file3.py. Instead, you are declaring a new local variable with the same name as the global variable, which shadows the global variable and prevents you from accessing its value.
To fix this issue, you should use the global keyword in the correct way in file2.py and file3.py. Here's an example of how you might do this:
# file2.py
from file1 import string_global
def func_local():
# Declare that the string_global variable is global
global string_global
string_global = "here i am"
print(string_global)
# file3.py
from file1 import string_global
def func_another_local():
# Declare that the string_global variable is global
global string_global
print("Are you still here? ",string_global)
By using the global keyword in this way, you can access the global string_global variable from file1.py in file2.py and file3.py.
Keep in mind that using global variables in this way is not always the best approach, and you should consider other options, such as passing the value of the global variable as an argument to the functions that need it, or using a class to manage the global state of your program.