explain this function to me, lambda confusion
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Mon May 19 06:16:56 EDT 2008
inhahe a écrit :
>> Both the responses offer lambda free alternatives. That's fine, and
>> given the terse documentation and problems that I had understanding
>> them, I would agree. So what applications are lambdas suited to? I
>> think the parameterised function model is one.
>> What else?
>
> i've hardly ever used lambdas since map() and filter() were replaced by list
> comprehension. two other uses I can think of for it are: using it as a
> sorting key (which takes a function and lambdas are perfect for that when a
> direct function isn't available. for example, lambda x: x.myName),
import operator
foos.sort(key=operator.attrgetter('myName'))
More information about the Python-list
mailing list