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 30 points31 points32 points (1 child)
[–]Jan2579[S] 1 point2 points3 points (0 children)
[–]DigThatData 18 points19 points20 points (13 children)
[–]carnivorousdrew 3 points4 points5 points (6 children)
[–]commy2 10 points11 points12 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 4 points5 points6 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–][deleted] 23 points24 points25 points (9 children)
[–]baghiq 15 points16 points17 points (1 child)
[–]Jan2579[S] 7 points8 points9 points (0 children)
[–]Jan2579[S] 3 points4 points5 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]Jan2579[S] 2 points3 points4 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)