21 ms·
From my personal experience, most developers that discover list comprehension etc. get excited about how much they can achieve with little code that they try to
by emsy 8y ago
From my personal experience, most developers that discover list comprehension etc. get excited about how much they can achieve with little code that they try to keep everything as small as possible. They end up using short, non-descriptive variable names and you need evaluate the code in your head to find out what a variable/list contains. It's even worse with non-sequential callbacks and closures.
- dorfsmay 8y agoIn Python I went back and forth: I discovered list comprehension and was exited and used them a lot. Then I went to multi level list comp. Then I realise I could never debug those so went back to loops for anything needing more than a single level. Finally I discovered Generator Expression which are basically like list comp, but lazy (not evaluated) and since then I break my code in a series of generator expression which I materialise at the end with a single list comprehension. This way I keep my code readable, it's a lot cleaner then a bunch of loops, and I also benefit of Python's special optimisation for list comprehension.
- blt 8y agoI like writing generator loops with the yield statement for more complex processing.
- sizeofchar 8y agoThat’s my style as well, and I followed the same path of yours!
- deleted 8y ago[deleted]