I want to share and write global variables of other files like c++.
For example, path.The network paths required for the file py are
All specified in the global function
I want to take global variables from other Python files and use them as network paths.
Network paths are often changed or added, so I'd like to manage them from one file.
I can't find this way. If anyone knows how to do it, please help me.
python variable share global-variable
"""
path_file.py
"""
TEMP_HOST = '0.0.0.0'
TEMP_PORT = 8000
After you fill it out
"""
another_file.py
"""
from yourpath.path_file import TEMP_HOST, TEMP_PORT
print(TEMP_HOST)
Can't we do it like this?
Or you can manage it with a class.
I manage both in the flask app.
© 2024 OneMinuteCode. All rights reserved.