Bash-like pipes in Python

Omar Abou Mrad omar.aboumrad at gmail.com
Wed Mar 16 12:20:51 EDT 2016


On Wed, Mar 16, 2016 at 5:39 PM, Steven D'Aprano <steve at pearwood.info>
wrote:

> On Thu, 17 Mar 2016 02:22 am, Omar Abou Mrad wrote:
>
> > Would be nice if this was possible:
> >
> >>>> get_digits = Filter(str.isdigit) | Map(int)
> >>>> 'kjkjsdf399834' | get_digits
>
>
> Yes it would. I'll work on that.
>
>
> > Also, how about using '>>' instead of '|' for "Forward chaining"
>
> Any particular reason you prefer >> over | as the operator?


Nothing major, only that it's closer to visual "forward" a la F#'s |>
operator.
I tend to see | as an indication of "OR" (bit or otherwise) rather than pipe
(which I completely understand why you picked it).

On a somewhat related note I had experimented with an overridden '|'
a while ago to lift conditions and compose them (which is what spurred
the get_digits question).

https://gist.github.com/omaraboumrad/8424298



More information about the Python-list mailing list