code: def expr(s):
      
  
      prog = re.compile('\{([^}]+)\}')
  
      def repl(matchobj):
          return "rec['%s']" % matchobj.group(1)
  
      return eval("lambda rec: " + prog.sub(repl, s))
docs: Construct a function operating on a table record.
  
      The expression string is converted into a lambda function by prepending
      the string with ``'lambda rec: '``, then replacing anything enclosed in
      curly braces (e.g., ``"{foo}"``) with a lookup on the record (e.g.,
      ``"rec['foo']"``), then finally calling :func:`eval`.
  
      So, e.g., the expression string ``"{foo} * {bar}"`` is converted to the
      function ``lambda rec: rec['foo'] * rec['bar']``