[Python-ideas] Syntax for passing lambdas to functions

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Feb 27 23:03:16 CET 2014


Chris Angelico wrote:

> Remember, def creates a function with a name.

It doesn't *have* to do that, though. If there is no
obvious name, it could use a generic fallback name, like
lambda does.

> def functionname(...):
>     ....
> table[key] = functionname

I don't see how that's intrinsically better.

> or:
> 
> table[key] = lambda(...): ...
> 
> to either set a name, or not set a name, as the case may be.

I don't see having a name vs. not having a name as
the most important criterion for deciding whether
to use a def or a lambda.

-- 
Greg


More information about the Python-ideas mailing list