r/badcode • • Apr 30 '22

python Looks like Python List Comprehension-phobia is a thing. This is a real commit by a teammate.

Post image
1.2k Upvotes

125 comments sorted by

View all comments

Show parent comment

44

u/CaitaXD May 01 '22

Filter being confusing is hilarious, it literally does what the name says it filters

12

u/Cerus_Freedom May 01 '22

I think a lot of it comes from not really encountering significant use of things like list comprehension, filter, map, even lambdas, outside of stuff like trying to code golf challenging problems. Makes it all seem a lot more daunting than it really is.

18

u/CaitaXD May 01 '22

Most for loops can be represented as map filter reduce or foreach

And I cannot be convinced that a naked for loop is somehow more readable.

It's just more comfortable because it's familiar

8

u/hey--canyounot_ May 01 '22

It is so confusing to me what kind of coding job people work where you aren't using those frequently, outside of 'pure front-end' positions that are essentially designers. In web dev (and when I did QA) I feel like I use them somewhere in most solutions.

4

u/Cerus_Freedom May 01 '22

I think that depends largely on whether you have well structured code. I, for one, do not. I'm currently staring at 50 lines of purely mapping and filtering database results, none of which actually lends to using map or filter because of poor design decisions.

1

u/hey--canyounot_ May 01 '22

My sympathies, dude.