def expr(s):

    prog = re.compile('\{([^}]+)\}')

    def repl(matchobj):
        return "rec['%s']" % matchobj.group(1)

    return eval("lambda rec: " + prog.sub(repl, s))
Construct a function operating on a table record.
dataset/ETHPy150Open alimanfoo/petl/petl/util/base.py/expr