Why functional Python matters
Dave Benjamin
ramen at lackingtalent.com
Tue Apr 15 21:40:12 EDT 2003
In article <eppstein-8427F2.18234715042003 at news.service.uci.edu>,
David Eppstein wrote:
> On Tue, Apr 15, 2003 at 11:04:06PM -0000, Dave Benjamin wrote:
>> > I think that list comprehensions bridge the gap somewhat between FP and OO
>> > methods, and this is one thing I really like them for. For instance:
>> >
>> > [obj.method(x) for x in data]
>> >
>> > looks nicer to me than:
>> >
>> > map(lambda x: obj.method(x), data)
>
> Sure, but wouldn't it be even better to use
> map(obj.method, data)
Yes, of course. I didn't think that example out thoroughly. This trick
works, but only if that method happens to be a function of one argument. See
Jp Calderone's last post about the message types - he identified the problem
I was trying to convey here.
Thanks,
Dave
More information about the Python-list
mailing list