Hacker News new | ask | show | jobs
by peterwaller 4623 days ago
My approach is frequently to "name" a complicated list comprehension by shoving it into a one or two-liner closure function in the current scope. Then you don't have to jump miles and the code which uses it becomes readable.
1 comments

So what is the advantage of this approach over having a comment beside it? Sounds slightly more complex to me.
Because comments can lie.

Also, it can be harder to express the generator in a useful way in English than the code itself if the code is well written.

The purpose is to make the code as clearly self describing as possible. I would only do it if it made the code read more like a human language and remove too much complexity from one place.