You are right.
On Sep 19, 2:14 pm, cjrh <[email protected]> wrote: > Hi > > With my editor cap on, I am working my way through the documentation. > The section on lambda, in the python language section of the book, > makes me uncomfortable. It says this: > > *** > The existence of lambda allows re-factoring an existing function in > terms of a different set of arguments. cache.ram and cache.disk are > web2py caching functions. > *** > > It is implied that the lambda keyword allows currying, when in fact > that functionality is provided by standard Python functions. For > example (using the example given in the text), > > >>> def f(a, b): return a + b > >>> g = lambda a: f(a, 3) > >>> g(2) > > 5 > > Could be written without lambda as > > >>> def f(a,b): return a + b > >>> def g(a): return f(a, 3) > >>> g(2) > > 5 > > The anonymity of lambda means that inline code is allowed, because no > prior declaration is needed in order to obtain a reference, as is the > case with def, but on the other hand, lambdas are limited to a single > expression, whereas def functions are not. Consider the next example: > > >>> number = 7 > >>> print cache.ram(str(number), lambda: isprime(number), seconds) > True > >>> print cache.ram(str(number), lambda: isprime(number), seconds) > > True > > Could be rewritten as > > >>> number = 7 > >>> def isprimecall: return isprime(number) > >>> print cache.ram(str(number), isprimecall, seconds) > True > >>> print cache.ram(str(number), isprimecall, seconds) > > True > > In conclusion, the description of lambda in the text is misleading. > Comments?

