[Python-Dev] Use an empty def as a lambda
ben+python at benfinney.id.au
Sat Sep 21 21:56:02 CEST 2013
Westley Martínez <anikom15 at gmail.com> writes:
> My reasoning is that we use class to make classes, lambda to make
> lambda functions, and def to make--well not defs--functions, which
> doesn't really make sense to me.
Your reasoning is flawed. There is no such thing in Python as a “lambda
Python has functions. It doesn't matter whether you use a ‘lambda’ or
‘def’ statement to create it, there's no resulting difference in the
type of the object. It is a function.
So: you make a class with a ‘class’ statement; you make a function using
either a ‘def’ statement or a ‘lambda’ expression. There is no third
type of object being discussed here.
\ “Faith may be defined briefly as an illogical belief in the |
`\ occurrence of the improbable.” —Henry L. Mencken |
More information about the Python-Dev