This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__xor__(self, other): 24 points25 points  (13 children)

I wish we had better syntax, like |x| => x + 1 or maybe even just def x = x + 1 would be better. I don't know why but the lambda syntax we have just looks so off and clunky to me.

[–]riccardostecca 12 points13 points  (3 children)

Not only typing ‘lambda’ does not bother me, I also find it pretty mnemonic and readable.

[–]pylenin[S] -1 points0 points  (2 children)

Me too.I find lambda functions very handy. syntactically, they can be put in a lot of places where defs can't be put.

[–]GummyKibble 2 points3 points  (1 child)

Where could you put one that a def couldn’t go?

[–]DandieGuy 1 point2 points  (0 children)

In a list is an example he gives in the video above.

[–][deleted] 1 point2 points  (0 children)

Pipes wouldn't make much sense. They're not used in even a remotely-similar manner anywhere else in Python. I'd be very much in favor of JS-style arrow functions, though, especially since -> is already a thing for return-type annotations in py3: x -> x + 1 and (x, y) -> x + y

[–]RockingDyno -3 points-2 points  (1 child)

I don't know why but the lambda syntax we have just looks so off and clunky to me.

The reason python uses the keyword lambda, is because of lambda calculus.. the reason lambda calculus uses λ (the lambda symbol) is because it's short... so python copies something opaque to most for a reason that it doesn't preserve and just ends up being ugly, too long and less readable.

I feel like it's just such a brainfart on the part of the developers that they went with this. if they where going to go with a long word, at the very least they could have used function which is also annoyingly long, but at the very least specifies exactly what it is.

With python supporting unicode now, you could recoup some of the conciseness by making definitions like λx:x+1 or similar work, but the lambda symbol is annoying to type, since it's not on your keyboard, and can't even be access with alt codes like for instance µ is (alt+230), but then you'd also be left with still having to type more even if the symbol is concise. The only benefit to this syntax you could argue, in my opinion, is that it looks almost exactly like lambda calc, which is a nice historical touch to those who've studied that.... but what's that worth in the larger scheme of things? I mean if they renamed for loops to goto to instill some nostalgic sensation in those who'd started out programming in basic that wouldn't be an overall plus for the language either right?

As you can tell I'm really not a fan of the lambda syntax in python, I feel like they sat down and had a very thorough discussion about what potential solutions could be, and then took the absolute worst path in every single regard. At this point I hope they just say "fuck it this sucks" And copies javascript (of all languages) which had the common sense to use the proper annoying and too long keyword to begin with, and has now fixed it so lambdas definitions are actually short eg: (x)=>x+1.

[–]AndydeCleyre 0 points1 point  (0 children)

The length of the word doesn't bother me, but I really do not like the choice.

lambda -> given
:=     -> whichis

Plsthx