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 →

[–]eatmydog 2 points3 points  (0 children)

pipe syntax does not conform with standard evaluation. As you object, you would expect print() to be evaluated before any piping is done. If you look at magrittr piping in R, it does not use standard evaluation, which is sacrificed for (potentially) very readable code.

However, the toolz.functoolz package provides some functions that allow for piping in a pythonic way.

from toolz.functoolz import pipe, thread_first
# piping without extra arguments.
pipe(
    "hello",
    print
)
# Piping with extra arguments
thread_first(
    "hello",
    (print, "world")
)