Functional pipes in python like %>% from R's magritrr

后端 未结 14 2231
春和景丽
春和景丽 2020-11-29 16:17

In R (thanks to magritrr) you can now perform operations with a more functional piping syntax via %>%. This means that instead of coding this: <

14条回答
  •  伪装坚强ぢ
    2020-11-29 16:57

    PyToolz [doc] allows arbitrarily composable pipes, just they aren't defined with that pipe-operator syntax.

    Follow the above link for the quickstart. And here's a video tutorial: http://pyvideo.org/video/2858/functional-programming-in-python-with-pytoolz

    In [1]: from toolz import pipe
    
    In [2]: from math import sqrt
    
    In [3]: pipe(12, sqrt, str)
    Out[3]: '3.4641016151377544'
    

提交回复
热议问题