3 ms·
Having a list comprehension in 2 lines is really a problem? I find very readable something like result = [something(value) + value * 2 for value
by jaimebuelta 14y ago
Having a list comprehension in 2 lines is really a problem? I find very readable something like
result = [something(value) + value * 2
for value in values]
I mean, I prefer one line, but if it has be in two (or more lines), I don't see the problem really
- mst 14y agoActually, with a minor tweak this gets even more readable - result = [something(value) + value*2 for value in values] I find indenting the subcaluse makes my eye flow naturally over the code. I'm normally doing this in perl, and often end up with functionalish code that looks like my @result = map { something($_) + $_*2 } grep { valid_candidate($_) } @all_candidates; but the same principle seems to apply nicely to both languages.