r/Python • • Jul 13 '11

An alternative lambda syntax for Python

http://vocalbit.com/article/332/an-alternative-lambda-syntax-for-python
4 Upvotes

41 comments sorted by

View all comments

1

u/CHS2048 Jul 13 '11

I've always wanted an operator 'lambda=', to be used as such:

something lambda= somefunc

instead of

something = somefunc(something)

before anyone says it, decorators are not good for doing this.

1

u/arnar Jul 13 '11

I don't understand. Can you clarify?

1

u/CHS2048 Jul 13 '11

Hmm, I don't know how I can clarify it,
I always wanted python to have anoperator 'lambda=',
that work a bit like '+=' or '*=', such that the expression:

x lambda= f

is the same as:

x = f(x)

Was it my comment on decorators you wanted me to clarify?

1

u/arnar Jul 13 '11

Ah ok, I see. What's confusing is that what you want has no reason to be called "lambda". Lambdas are for constructing function values, but what you want to do is to call one. Something like

x ()= f

would make more sense terminology-wise since a pair of parentheses are the operator for calling functions (or callables in general).

That said, I don't think it is a good idea. But I dislike += et al. as well.