The other solutions posted here didn't work for me, because:
import *
didn't work for me, as i need a way to override them by choosing another fileSo I ended up using Configparser
and globals().update()
Test file:
#File parametertest.cfg:
[Settings]
#Comments are no Problem
test= True
bla= False #Here neither
#that neither
And that's my demo script:
import ConfigParser
cfg = ConfigParser.RawConfigParser()
cfg.read('parametertest.cfg') # Read file
#print cfg.getboolean('Settings','bla') # Manual Way to acess them
par=dict(cfg.items("Settings"))
for p in par:
par[p]=par[p].split("#",1)[0].strip() # To get rid of inline comments
globals().update(par) #Make them availible globally
print bla
It's just for a file with one section now, but that will be easy to adopt.
Hope it will be helpful for someone :)