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

2013-08-01 Thread Steven D'Aprano
Hi Alexander, On 02/08/13 00:48, Alexander Shorin wrote: Hi Ronald, I understand this, but I'm a bit confused about fate of lambdas with such guideline since I see no more reasons to use them with p.9 statement: long lines, code duplicate, no mock and well tests etc. - all these problems could

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

2013-08-01 Thread Alexander Shorin
Hi Steven, On Thu, Aug 1, 2013 at 7:06 PM, Steven D'Aprano st...@pearwood.info wrote: Hi Alexander, On 02/08/13 00:48, Alexander Shorin wrote: Hi Ronald, I understand this, but I'm a bit confused about fate of lambdas with such guideline since I see no more reasons to use them with p.9

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

2013-08-01 Thread Chris Angelico
On Thu, Aug 1, 2013 at 5:58 PM, Alexander Shorin kxe...@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,

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

2013-08-01 Thread Brett Cannon
On Thu, Aug 1, 2013 at 12:58 PM, Alexander Shorin kxe...@gmail.com wrote: Hi Steven, On Thu, Aug 1, 2013 at 7:06 PM, Steven D'Aprano st...@pearwood.info wrote: Hi Alexander, On 02/08/13 00:48, Alexander Shorin wrote: Hi Ronald, I understand this, but I'm a bit confused about

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

2013-08-01 Thread Stephen J. Turnbull
Chris Angelico writes: On Thu, Aug 1, 2013 at 5:58 PM, Alexander Shorin kxe...@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]

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

2013-08-01 Thread André Malo
* Stephen J. Turnbull wrote: Chris Angelico writes: On Thu, Aug 1, 2013 at 5:58 PM, Alexander Shorin kxe...@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

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

2013-08-01 Thread Vito De Tullio
Steven D'Aprano wrote: Lambda is still useful for the reason lambda has always been useful: it is an expression, not a statement, so you can embed it directly where needed. are there some possibilities to change def to an expression? do I need to wait 'till python9k? yes, this brings to the