2 ms·
Why not use | as the pipe operator? Just use __or__ instead of __add__ I have done something similar too once in a shell-like Python CLI I worked on. Can also
by ehsankia 7y ago
Why not use | as the pipe operator? Just use __or__ instead of __add__
I have done something similar too once in a shell-like Python CLI I worked on. Can also use __ror__ to be able to pass primitives into your commands like `[1, 2, 3] | SumCmd() | PrintCmd()`
I do agree that typing something like that, especially when working in a shell, is much nicer than having to go back and forth all the time to type `print(sum([1,2,3]))`
Here it is mentioned in a talk about Python Aesthetics by Brandon Rhodes: https://www.youtube.com/watch?v=x-kB2o8sd5c&t=8m24s https://www.youtube.com/watch?v=x-kB2o8sd5c&t=8m24s
- pinopinopino 7y agoOh that is possible? I am not that deep into python honestly. Looks much neater to use |.