4 ms·
Sometimes it is, sometimes it's not. If you allow me to generalize this to list comprehensions vs. standard functional techniques, sometimes the list comprehens
by scott_s 19y ago
Sometimes it is, sometimes it's not. If you allow me to generalize this to list comprehensions vs. standard functional techniques, sometimes the list comprehension is cleaner. Take the list comprehension
[f for f in os.listdir('.') if f.endswith('.csv') and not f.endswith('_avg.csv')]
The lambda alternative (which would make a great blog name) is
filter(lambda f: f.endswith('.csv') and not f.endswith('_avg.csv'), os.listdir('.'))
I find the list comprehension cleaner because it introduces less noise.
- avinashv 19y agoAgreed. > The lambda alternative (which would make a great blog name) I'm stealing that.
- inklesspen 19y agoDammit!