Guest User

Untitled

a guest
Jan 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. def config2dict(fname):
  2. d = {}
  3. codeobj = compile(open(fname).read(), 'myconfig', 'exec')
  4. exec(codeobj, d)
  5. return d
  6.  
  7. dd = config2dict("myconfig.cfg")
  8. print(dd)
  9.  
  10. DB_HOST = 172.123.125.34
  11. DB_USER = app_user
  12. DB_PASS = lly4paw
  13.  
  14. Traceback (most recent call last):
  15. File "mytest.py", line 19, in <module>
  16. dd = config2dict("myconfig.cfg")
  17. File "mytest.py", line 14, in config2dict
  18. codeobj = compile(open(fname).read(), 'myconfig', 'exec')
  19. File "myconfig", line 1
  20. DB_HOST = 172.123.125.34
Add Comment
Please, Sign In to add comment