Hacker News new | ask | show | jobs
by RussianCow 2018 days ago
I'm not sure what specific "functions" you're talking about, but Python generally encourages a procedural style of programming as opposed to functional. The rationale is that functional code can be really difficult to read if you aren't already familiar with the idioms and terminology, whereas it's pretty easy to mentally parse and understand a `for` loop. So in that sense, list comprehensions are about as far as Python goes in that direction; there is no syntactic equivalent to the pipe operator, and no way to write reduce or similar operations as succinctly as you can in functional languages.
2 comments

Having read plenty of python numerical code, I'm not sure "easy to parse and understand" is what exactly comes to mind.
Most of the problem comes from Pandas which is of course R-inspired.
Yup, it's a terrible shame that pandas started off as a base-R clone in Python.

Now, the only time I write base-R like code is in Python, which is pretty weird.

It's also strange as sklearn is beautiful, and in general python libraries are nicer than the equivalents in R, but pandas is a large, warty exception.

And just in brief as to what the pipe generally does without the syntax available. If you have functions x and y which take 1 argument. Where |> is the piping syntax

y(1) |> x would be equivalent to x(y(1)) in python.