Yes, you can do that. The normal way to do that is to create a source file with the variable definitions that you then import into other source files that want to use them. A simple example:
# This is "my_app_globals.py"
MY_APP_NAME = "My Application"
MY_APP_VERSION = "1.02"
MY_APP_NVERSION = (1, 2)
Then you can ues that file in another Python source file with something like:
# This is "main.py"
import my_app_globals
print("App Name:", my_app_globals.MY_APP_NAME)
print("Version: ", my_app_globals.MY_APP_VERSION)
The longer story is that import
reads and compiles all of a single Python source file and puts of of the definitions into a module
with a name that is (by default) the source file name without the .py suffix. (The compilation part will be skipped if an up-to-date precompiled file is found, but that's a run-time optimization. The principle is the same.) Any top-level code (not in a class or function definition) will be run once at import time to "initialize the module". All global names in that source file are stored in the module, available to other modules import it.
Those names are pretty long. You can shorten them in a couple of ways. One way that's pretty safe is to simply rename the module on import:
import my_app_globals as gbls
print("App Name:", gbls.MY_APP_NAME)
That makes "gbls" a name your program can use to access the "my_app_globals" module. The original module is only imported once per execution of your program. Another way is to use another form of the import …