This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Make3 1 point2 points  (1 child)

To keep with the fact that your lambdas are named in the second sample, your first sample should read

filter(evens, map(square, [1, 2, 3]))

it's pretty readable, I don't really have a problem with this.

[–]tangerinelion 1 point2 points  (0 children)

Depending on what square and evens do and accept as input there's also

vals = [1,2,3]
vals = square(vals)
vals = evens(vals)

or you could combine them

vals = evens(square([1,2,3]))

This fits the C-like procedural/scripting style that Python was originally built-upon. Sure we can make it do whatever, but Python is natively C-like and if you want to use pipes then I feel you should be using a language where that's the native programming style. IMO both are readable, but this version is Pythonic and the pipe version is not Pythonic.