Partially evaluated functions

Neil Schemenauer nas at python.ca
Tue Jun 19 20:19:38 EDT 2001


This works in 2.1 (a little more magic is needed for older
Pythons):

>>> from __future__ import nested_scopes
>>> def conv(b, c):
...   return lambda a: (a + b) * c
... 
>>> faren2cel = conv(-32., 5./9)
>>> faren2cel
<function <lambda> at 0x810f45c>
>>> faren2cel(10)
-12.222222222222223
>>> faren2cel(-40)
-40.0

Not exactly what you want but close.

  Neil




More information about the Python-list mailing list