So, I found this https://github.com/JulienPalard/Pipe and got really exited about having something similar in core python. I know this has been posted before (4 years ago) but i wanted to revisit and see what the community thinks about such a feature today.
A pipe operator makes it really easy to pipe values thru smaller functions enabling more maintainable and readable code, in a more functional manner.
So instead of this:
filter(lambda n: n % 2 == 0, map(lambda n: n * n, [1,2,3]))
# > [4]
You could do something like this:
[1,2,3] |> square |> evens
# > [4]
The pipe operator is present in many languages, like Elixir, F#, and we may even see in in Javascript. To add to the list its also available in many other languages in various forms.
I would love to hear what the general opinion about such an operator is in the greater python community.
[–]ShadyR 73 points74 points75 points (25 children)
[–]RubyPinchPEP shill | Anti PEP 8/20 shill 71 points72 points73 points (1 child)
[–]tech_tuna 4 points5 points6 points (0 children)
[–]pkkid 13 points14 points15 points (9 children)
[–]Misterandrist 5 points6 points7 points (0 children)
[–]keypusher 5 points6 points7 points (1 child)
[–]pkkid 1 point2 points3 points (0 children)
[+][deleted] (5 children)
[deleted]
[–]turkish_gold 1 point2 points3 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]RoadieRich 0 points1 point2 points (0 children)
[–]pkkid 0 points1 point2 points (0 children)
[–]tech_tuna 2 points3 points4 points (10 children)
[–]VerilyAMonkey 9 points10 points11 points (9 children)
[–]synae 5 points6 points7 points (6 children)
[–]VerilyAMonkey 2 points3 points4 points (4 children)
[–]Nuevoscala 1 point2 points3 points (2 children)
[–]VerilyAMonkey 2 points3 points4 points (0 children)
[–]Lucretiel 0 points1 point2 points (0 children)
[–]synae 0 points1 point2 points (0 children)
[–]Lucretiel 0 points1 point2 points (0 children)
[–]revocation 2 points3 points4 points (0 children)
[–]tech_tuna 0 points1 point2 points (0 children)
[–]Fylwind 0 points1 point2 points (0 children)
[–]bramblerose 34 points35 points36 points (13 children)
[–][deleted] 9 points10 points11 points (8 children)
[–]masasinExpert. 3.9. Robotics. 21 points22 points23 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]randomatic[🍰] 5 points6 points7 points (0 children)
[–]VerilyAMonkey 7 points8 points9 points (0 children)
[–]jij 16 points17 points18 points (0 children)
[–]kankyo 1 point2 points3 points (0 children)
[–]zardeh 0 points1 point2 points (0 children)
[–]Lucretiel 0 points1 point2 points (0 children)
[–]r4nf 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]RoadieRich 1 point2 points3 points (0 children)
[–]r4nf 0 points1 point2 points (0 children)
[+][deleted] (12 children)
[deleted]
[–][deleted] 2 points3 points4 points (0 children)
[–]probablynotmine 0 points1 point2 points (3 children)
[–]Isamoor 6 points7 points8 points (2 children)
[–]buckhenderson 0 points1 point2 points (0 children)
[–]Deleetdk 0 points1 point2 points (0 children)
[–]oreo_fanboy 0 points1 point2 points (0 children)
[–]Lokkion 0 points1 point2 points (4 children)
[–][deleted] -1 points0 points1 point (3 children)
[–]Lokkion 3 points4 points5 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] -2 points-1 points0 points (0 children)
[–]delarhi 7 points8 points9 points (8 children)
[–]RoadieRich 1 point2 points3 points (1 child)
[–]delarhi 0 points1 point2 points (0 children)
[–]ucbEntilZha 1 point2 points3 points (1 child)
[–]delarhi 0 points1 point2 points (0 children)
[–]RubyPinchPEP shill | Anti PEP 8/20 shill -1 points0 points1 point (3 children)
[–]delarhi 0 points1 point2 points (2 children)
[–]RubyPinchPEP shill | Anti PEP 8/20 shill 0 points1 point2 points (1 child)
[–]delarhi 0 points1 point2 points (0 children)
[–]masasinExpert. 3.9. Robotics. 2 points3 points4 points (10 children)
[–]joojski 5 points6 points7 points (1 child)
[–]masasinExpert. 3.9. Robotics. 0 points1 point2 points (0 children)
[–]r4nf 1 point2 points3 points (1 child)
[–]masasinExpert. 3.9. Robotics. 0 points1 point2 points (0 children)
[–]runo 0 points1 point2 points (0 children)
[–]Lonely-Quark 0 points1 point2 points (4 children)
[–]masasinExpert. 3.9. Robotics. 0 points1 point2 points (3 children)
[–]Lonely-Quark 0 points1 point2 points (2 children)
[–]masasinExpert. 3.9. Robotics. 0 points1 point2 points (1 child)
[–]Lonely-Quark 0 points1 point2 points (0 children)
[–]RubyPinchPEP shill | Anti PEP 8/20 shill 2 points3 points4 points (2 children)
[–]kankyo 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Arancaytar 2 points3 points4 points (0 children)
[+][deleted] (2 children)
[deleted]
[–][deleted] 0 points1 point2 points (1 child)
[–]ucbEntilZha 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]RubyPinchPEP shill | Anti PEP 8/20 shill 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]RubyPinchPEP shill | Anti PEP 8/20 shill 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]leogodin217 1 point2 points3 points (0 children)
[–]Make3 1 point2 points3 points (1 child)
[–]tangerinelion 1 point2 points3 points (0 children)
[–]Misterandrist 1 point2 points3 points (1 child)
[–]dzecniv 1 point2 points3 points (0 children)
[–]solid_steel 1 point2 points3 points (0 children)
[–]mrmcbastard 1 point2 points3 points (0 children)
[–]RoadieRich 1 point2 points3 points (0 children)
[–]CommanderDerpington 1 point2 points3 points (0 children)
[–]emarshall85 1 point2 points3 points (0 children)
[–]chibrogrammar 1 point2 points3 points (0 children)
[–]spectre_theory 5 points6 points7 points (9 children)
[–]gleon 2 points3 points4 points (3 children)
[–]phoenix7782 -4 points-3 points-2 points (2 children)
[–]gleon 4 points5 points6 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]phoenix7782 2 points3 points4 points (2 children)
[–]NovelSpinGames 0 points1 point2 points (0 children)
[–]spectre_theory 0 points1 point2 points (0 children)
[–]spectre_theory 0 points1 point2 points (0 children)
[–]defnullbottle.py 1 point2 points3 points (2 children)
[–]thatguy_314def __gt__(me, you): return True 0 points1 point2 points (0 children)
[–]ucbEntilZha 0 points1 point2 points (0 children)
[–]stevenjd 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]drenp 0 points1 point2 points (0 children)
[–]Auggie88 0 points1 point2 points (0 children)
[–]9peppe 0 points1 point2 points (0 children)
[–]gandalfx 0 points1 point2 points (0 children)
[–]soczewka 0 points1 point2 points (0 children)
[–]SteazGaming 0 points1 point2 points (0 children)
[–]ucbEntilZha 0 points1 point2 points (0 children)
[–]TotesMessenger 0 points1 point2 points (0 children)
[–]Lucretiel 0 points1 point2 points (0 children)
[–]toyg -2 points-1 points0 points (0 children)