A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-August/127718.html below:

[Python-Dev] Lambda [was Re: PEP 8 modernisation]

[Python-Dev] Lambda [was Re: PEP 8 modernisation]Stephen J. Turnbull stephen at xemacs.org
Thu Aug 1 21:41:19 CEST 2013
Chris Angelico writes:
 > On Thu, Aug 1, 2013 at 5:58 PM, Alexander Shorin <kxepal at gmail.com> wrote:
 > > fun = lambda i: i[1]
 > > for key, items in groupby(sorted(items, key=fun), key=fun):
 > >   print(key, ':', list(items))
 > 
 > I'd do a direct translation to def here:
 > 
 > def fun(i): return i[1]
 > for key, items in groupby(sorted(items, key=fun), key=fun):
 >   print(key, ':', list(items))

As long as it's about readability, why not make it readable?

    def second(pair): return pair[1]
    for key, items in groupby(sorted(items, key=second), key=second):
        print(key, ':', list(items))

I realize it's somewhat unfair (for several reasons) to compare that
to Alexander's "fun = lambda i: i[1]", but I can't help feeling that
in another sense it is fair.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4