
May 31, 2007
2:22 a.m.
On 5/30/07, Steve Howell <showell30@yahoo.com> wrote:
======= THEORETICAL
Valid Python:
row = {'salary': 50000} def convert_to_euros(amt): return amt / 2 x = rowexpr: convert_to_euros(salary) print x(row) # prints 25000
def rowexpr(expr): ... def evaluate(row): ... d = dict(row) ... d.update(globals()) ... exec '__result__ = ' + expr in d ... return d['__result__'] ... return evaluate ... def convert_to_euros(amt): ... return amt / 2 ... x = rowexpr('convert_to_euros(salary)') row = dict(salary=50000) print x(row) 25000
STeVe -- I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy