How to determine config file path in python? -


i have module needs initialize settings reading config file. directory structure looks this:

root\     config\         conf.cfg     src\         module1.py 

i'm fine when set relative path ../config/conf.cfg , run module in current directory. when import module somewhere else , run in directory run problems.

how should set path module looks in same relative location (eg 1 directory module located) , how ensure works other people download repo (who may not have root in same place)?

os.path.realpath(__file__)  

will give path of current file, resolving symlinks in path. works fine on machine.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -