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

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 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 her

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 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

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 wrote: > Hi Steven, > > On Thu, Aug 1, 2013 at 7:06 PM, Steven D'Aprano > 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 w

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 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

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 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 >> statem

[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