I\'ve got a python project with a configuration file in the project root. The configuration file needs to be accessed in a few different files throughout the project.
To get the path of the "root" module, you can use:
import os import sys os.path.dirname(sys.modules['__main__'].__file__)
But more interestingly if you have an config "object" in your top-most module you could -read- from it like so:
app = sys.modules['__main__'] stuff = app.config.somefunc()