lambda ??
Benjamin Niemann
b.niemann at betternet.de
Fri Aug 27 04:17:16 EDT 2004
lambda returns the functions, thus can be used *in* an expression or
function call, when a callable is required. This is often a useful shortcut.
But according to another thread 'lambda' is one candidate for things
that are dropped in a future version of Python...
Michael Foord wrote:
> I'm starting to read through the developer works article on Functional
> Programming - http://www-106.ibm.com/developerworks/library/l-prog.html
>
> It starts by giving some basic examples using lambda. What I'm
> wondering is what's the actual difference between these two forms ?
>
> pr = lambda s:s
> *and*
> def pr(s):
> return s
>
> Both bind the name 'pr' to a function object that does the same thing
> ?? I know that lambda functions can only be a single expression......
>
> Is it just a basic example (and so in this case there is no
> difference).. or am I missing something. (What's the point of an
> 'anonymous' function... if you give a name to it !!).
>
> Regards,
>
> Fuzzy
>
> http://www.voidspace.org.uk/atlatnibots/pythonutils.html
More information about the Python-list
mailing list