Re:Comparing the Same Project in Rust, Haskell, C++, Python,...
by xenator on Sunday June 16, 2019 @01:01PM
(#20196496)
List of standard methods of this kind https://docs.python.org/3/library/itertools.html
Re:Comparing the Same Project in Rust, Haskell, C++, Python,...
by tanin on Sunday June 16, 2019 @02:25PM
(#20197064)
Yes, itertools is great. But its stblib is still much lighter than Scala's and Ruby's.
Actually, that seems to be the direction/principle of Python, where it is less inclined to add a helper function.
"It has been discussed ad nauseam on comp.lang.python. People seem to enjoy writing their own versions of flatten more than finding legitimate use cases that don't already have trivial solutions." from https://softwareengineering.stackexchange.com/questions/2542...
Not that this is better or worse. It's just that, on the brevity aspect, Python code is gonna be longer.
Another example is that Scala offers a lot of ways to process a list like foldLeft, foldRight, unzip, headOption, lastOption, flatMap, groupBy, and many methods around Map, Set, and etc. Python probably doesn't offer many of these methods.
Of course, this comes with the cost of higher learning curve.