>>> def genFun(expr, locs):
...     return lambda x: eval('min(Max,max(Min,%s))' % expr, locs, {'x':
x})
... 
>>> fun = genFun("A*x+off", {'A': 3.0, 'off': -0.5, 'Max': 2.0,  'Min':
-2.0} )
>>> fun
<function <lambda> at 0x011B1470>
>>> fun(0)
-0.5
>>> fun(-10)
-2.0
>>> fun(10)
2.0
>>> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to