[[x,f(x)] for x in list that maximizes f(x)] <--newbie help

Alex Martelli aleax at mail.comcast.net
Fri Dec 2 10:19:40 EST 2005


<bonono at gmail.com> wrote:
   ...
> As while DSU is a very smart way to guard the max compare thing, it is
> still being introduced as a way that is not related to the original
> problem, i.e. I just want to compare f(x)

And that's why in 2.5 you'll just code max(mylist, key=f) to express
this intent exactly -- that's precisely what 'key=' means.


Alex



More information about the Python-list mailing list