News for hackers. Stuff that matters.
Re:Python 3.6.0 released by lmm on Friday December 23, 2016 @11:56AM (#13245722)
There's a lot of value in having the option of using top-level functions e.g. len. Sometimes something is more natural as a method, sometimes it's more natural as a function. In the specific case I probably agree with you, but I don't think any of the differences qualify as "crazy"; generators being lazy by default is a reasonable choice (though I think the wong one), map is often used partially applied so it's nice to have it available as a function, => was only recently added to javascript and I would hope Python will get something similar sooner or later (though I'd rather have scala-style _).
Re:Python 3.6.0 released by ufmace on Friday December 23, 2016 @02:46PM (#13246812)
I read that apparently it is impossible to add a true lambda functionality to Python because of the whitespace blocks thing. There's intentionally no way to block multiple statements together except to have them on multiple lines sharing an indent level, which means there's no way to write a lambda longer than a single expression and have a syntax for it that makes sense.
Re:Python 3.6.0 released by lmm on Friday December 23, 2016 @07:14PM (#13247961)
That issue has never really bothered me tbh. If you're writing in functional style then everything tends to be a single expression anyway, and in the rare cases where you need statements the function tends to be complex enough to be worth naming IMO.
Re:Python 3.6.0 released by otakucode on Friday December 23, 2016 @12:20PM (#13245881)
What does the _ do in Scala? I've not used Scala, and it wasn't terribly clear from context unless you mean they use _ exactly as javascript uses => (which would seem really weird to me so I'm assuming its different, apologies if that is asinine).
Re:Python 3.6.0 released by Nullabillity on Friday December 23, 2016 @02:27PM (#13246720)
_ is a placeholder for the next lambda argument. So, for example, `x => x.blah()` could be rewritten as `_.blah()`, and `x => blah(x)` could be rewritten as `blah(_)` (or, since we don't need partial application here, simply `blah`).

It also works for multiple arguments: `_ * _` is equivalent to `(x, y) => x * y`, which is really `(x, y) => x.*(y)`.

Re:Python 3.6.0 released by lmm on Friday December 23, 2016 @12:42PM (#13246015)
"_" is kind of the equivalent of "x => x" (only rather than x it's some temporary generated name that doesn't overlap with anything else). So you'd write "_ * 10" rather than "i => i * 10"
Re:Python 3.6.0 released by spraak on Friday December 23, 2016 @12:03PM (#13245784)
All good points, thanks for explaining!