import re
r = re.compile("#{([^}]*)}")
def I(string):
def eval_str_match(m):
return str(eval(m.group(1)))
return r.sub(eval_str_match,string)
* besides python taste/style/standards
Is there a nicer succinct way to call it then a single letter method?
Is there anything the regex could miss?
should I use repr instead of str ?
I know that eval can be dangerous but I can't see why
I("#{some_func()}\n")
is worse then
"%s\n" % str(some_func())