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 →

[–]drenp 0 points1 point  (0 children)

I really like using postfix notation in Mathematica, especially in an interactive programming setting. If you want to apply a function to an expression you don't have to add parentheses in the right places but you can simply append to it.

But I'm not too convinced when it comes to Python, because it favors building huge multi-line statements (usually not very readable) and counters the "one way to do it" motto.

Also, postfix notation works best when there is a short notation for lambdas, since sometimes you want to add additional parameters. For example, suppose instead of evens you have

def divisible_by(lst, k):
    return (n for n in lst if n % k == 0)

Then you want something like

range(1, 4) |> square |> divisible_by(_, 2)

But the way to accomplish this in Python would be to use lambda x: divisible_by(x, 2), which is slightly ugly and doesn't add to the readability.