Let-expressions

S

sloisel

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?

Thanks,

Seb
 
T

Terry Reedy

sloisel said:
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.
 
C

Chris Rebert

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
 
S

sloisel

Thanks for the quick replies.

I didn't want statements in my expressions, just let-expressions.
That's okay, it was just a question.

Sébastien Loisel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,507
Members
48,193
Latest member
DannyRober

Latest Threads

Top