Elixir's pipe operator in Python
iex> [1, , 3] |> List.flatten() [1, 2, 3]
iex> inc = fn x -> x + 1 end iex> dec = fn x -> x - 1 end iex> square = fn x -> x * x end iex> 5 |> inc.() |> dec.() |> square.() 25
Today, just for fun, I tried to implement something similar in Python. Here is the result:
So, you can write something like:
>>> 5 |P| inc |P| dec |P| square 25
Obviously, this is just a toy: it does not implement all the features available in the Elixir's one, but it was fun!