Let-expressions

Chris Rebert clp2 at rebertia.com
Fri Apr 3 20:20:51 EDT 2009


On Fri, Apr 3, 2009 at 4:18 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> sloisel wrote:
>>
>> Dear All,
>>
>> I searched this group and found that there have been discussions about
>> introducing a let expression to the language so that you can define
>> local variables in a lambda. I.e., something like f=lambda x: let
>> y=x^2 in sin(y). (My syntax is unpythonic, but I hope you get it).
>>
>> Can someone tell me what eventually happened?
>
> The discussions ended.
> Proposals for assignment expressions have been rejected.

To elaborate slightly, if you need anything more complicated than a
single expression, then *don't use a lambda*. Just use a named
function. It's much clearer and easier.
Proposals to extend lambda usually spiral/evolve into wanting to make
lambda multi-line, which has repeatedly been found to be incompatible
with Python's indentation-based syntax; and, again, you can just use a
named function.

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list