我使用第三方的pipe管道库,来进行一些类似linux sh中管道方式运算,遇到疑惑。见如下代码:
>>> from pipe import *
>>> [1, 2, 3] | sum
>>> 6
上面这段代码,管道描述符|
在python中不是按位或的运算符吗,为这么在这里可以作为类似linux下的管道符呢?查看pipe.py源文件,没有发现重载这个运算符啊?
大家讲道理2017-04-17 14:53:55
Found it, carefully looked at the pipe.py file, and found that the class Pipe has re-added the bitwise OR operator, realizing a function similar to the pipe operator in Linux sh.
/
division operator is overloaded and used as a connection operator, so pay special attention to this type of operator overloading in the future.