Skip to content

Instantly share code, notes, and snippets.

@agumonkey
Created September 27, 2014 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agumonkey/ed3b323447c44d72d242 to your computer and use it in GitHub Desktop.
Save agumonkey/ed3b323447c44d72d242 to your computer and use it in GitHub Desktop.
attempt to recreate config [key = value] file loader with comments and more
def load(c):
d = {}
with open(c) as cnf:
for l in cnf.readlines():
if not l.startswith('#'):
k,v = l.split('=',1)
d[k] = v.strip()
else:
if l.startswith('##'):
instr = l[2:]
print('<instr>',instr)
def stx(i):
return "({i})({v})".format(i=i,v='v')
print(eval(stx(instr),{'v':'foo'}))
else:
print('<comment>',l[1:])
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment