Currently I have config.py in my package and I can access variables defined in config.py from other py files as
import config
var1 = config.var1
First of all, Can I pass file as argument?
test.py config.py
But is there way to pass config file through command line as argument and access the variables defined in it? I see there is sys module to get arguments passed through command line. But can I get variables defined in passed file?
edit
Now I am able to access variables in passed file as __import__(sys.argv[1]) and called python test.py config. But can I call config.py file by giving pythonpath? e/g/ python test.py ~/Desktop/config or PYTHONPATH='~/Desktop/' python test.py config? Because if I do this I get no module error.
my_script.py a=1 b=abc d=1,23,5?import by filename is not supportedI tried__import__(sys.argv[1])and passedpython test.py ./config.py