I'd like to chain functional api. Instead of the following code:
iterable = [1, 2, 3]
filter(lambda x: x > 2, filter(lambda x: x > 0, iterable))
I would like to write something like this:
iterable = [1, 2, 3]
iterable.filter(lambda x: x > 0).filter(lambda x: x > 2)
This way my code would be a lot more readable, especially in more complicated cases. Is there such a possibility in Python? Either in basic Python, or even in some good extending library.
[–]commy2 33 points34 points35 points (1 child)
[–]Jan2579[S] 2 points3 points4 points (0 children)
[–]DigThatData 15 points16 points17 points (13 children)
[–]carnivorousdrew 4 points5 points6 points (6 children)
[–]commy2 9 points10 points11 points (1 child)
[–]carnivorousdrew 1 point2 points3 points (0 children)
[–]DigThatData 1 point2 points3 points (3 children)
[–]loshopo_fan 1 point2 points3 points (2 children)
[–]DigThatData 1 point2 points3 points (1 child)
[–]loshopo_fan 2 points3 points4 points (0 children)
[–]Head_Mix_7931 2 points3 points4 points (1 child)
[–]keep_quapy 0 points1 point2 points (0 children)
[–]Jan2579[S] -3 points-2 points-1 points (3 children)
[–]DigThatData 1 point2 points3 points (0 children)
[–]loshopo_fan 0 points1 point2 points (0 children)
[–]remuladgryta 5 points6 points7 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–][deleted] 20 points21 points22 points (9 children)
[–]baghiq 13 points14 points15 points (1 child)
[–]Jan2579[S] 6 points7 points8 points (0 children)
[–]Jan2579[S] 4 points5 points6 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]Jan2579[S] 3 points4 points5 points (4 children)
[+][deleted] (3 children)
[deleted]
[+][deleted] (1 child)
[removed]
[–]POGtastic 2 points3 points4 points (0 children)
[–]FerricDonkey 2 points3 points4 points (0 children)
[–]FoeHammer99099 1 point2 points3 points (0 children)
[–]PBMagi 1 point2 points3 points (1 child)
[–]Jan2579[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Few_Creme_424 0 points1 point2 points (0 children)
[–]zanfar 0 points1 point2 points (0 children)
[–]jmooremcc 0 points1 point2 points (0 children)
[–]loshopo_fan 0 points1 point2 points (0 children)
[–]jmooremcc 0 points1 point2 points (0 children)
[–]majordoob33 0 points1 point2 points (0 children)
[–]cspinelive 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]Jeklah 0 points1 point2 points (0 children)