Hacker News new | ask | show | jobs
by lucian1900 5169 days ago
Adding function literals to Python would be nice. Something to turn "inc = lambda x: x + 1" into "inc = def(x): return x + 1".

But blocks? They're a misfeature of Ruby, badly copied from Smalltalk.

[edit: added "return"]

1 comments

It looks like you changed "lambda" to "def" and added parentheses. It seems like that feature is already there...
Perhaps my example was crap. They would also allow anything inside them.
The problem with multiline lambdas it that no one knows a good way to indent them. If they weren't butt-ugly python would probably already have them.
"The problem with multiline lambdas in Python is that no one knows a good way to indent them."

How about new keyword(s)? "begin" and "end"? I imagine this has thoroughly been discussed ad-nauseum. Is there a good synopsis?

Basically, there is no scope or block ending token anywhere else in python. And Guido thinks inline multi-line anonymous functions make programs harder to understand.
I'm not sure it's that big a problem. CoffeeScript handles this pretty well using indentation.

CS has ambiguous cases because of optional ( ), but that wouldn't be the case with Python anyway.