[Python-ideas] Proposal for function expressions

Chris Rebert pyideas at rebertia.com
Wed Jul 15 05:55:47 CEST 2009


On Tue, Jul 14, 2009 at 8:50 PM, George Sakkis<george.sakkis at gmail.com> wrote:
> On Tue, Jul 14, 2009 at 3:16 PM, Paul Moore<p.f.moore at gmail.com> wrote:
>
>> 2009/7/14 Chris Perkins <chrisperkins99 at gmail.com>:
>>>
>>> y = sorted(x, key=&) do(item):
>>>    name = item.split('-')[1]
>>>    return name.upper()
>>>
>>> I think that forcing that two-line block of code to have a name would
>>> serve no purpose - it's abundantly clear what it does.
>>
>> That's a very telling statement. To me, that code is utterly baffling.
>> (Seriously! Without analysing it line by line, it means nothing to
>> me).
>
> Seconded, there's too much going on ('&', what's "do", a function ?,
> what's "item" ?, etc.). FWIW the only readable suggestion for
> multiline lambdas with almost zero learning curve I have seen is the
> one implemented in Boo, anonymous def and regular indentation:
>
> y = sorted(x, key=def (item):
>                               name = item.split('-')[1]
>                               return name.upper()
>               )
>
> There must be somewhere posted the reason this was rejected but my
> google-fu is failing me.

IIRC, it screws with the essential statement-expression dichotomy of Python:
http://unlimitednovelty.com/2009/03/indentation-sensitivity-post-mortem.html

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-ideas mailing list