Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def config2dict(fname):
- d = {}
- codeobj = compile(open(fname).read(), 'myconfig', 'exec')
- exec(codeobj, d)
- return d
- dd = config2dict("myconfig.cfg")
- print(dd)
- DB_HOST = 172.123.125.34
- DB_USER = app_user
- DB_PASS = lly4paw
- Traceback (most recent call last):
- File "mytest.py", line 19, in <module>
- dd = config2dict("myconfig.cfg")
- File "mytest.py", line 14, in config2dict
- codeobj = compile(open(fname).read(), 'myconfig', 'exec')
- File "myconfig", line 1
- DB_HOST = 172.123.125.34
Add Comment
Please, Sign In to add comment