4 ms·
Yeah I think using a list comprehension is overkill. The main reason I like list comprehensions is because I don't introduce variables (even temporarily) that I
by CogitoCogito 3y ago
Yeah I think using a list comprehension is overkill. The main reason I like list comprehensions is because I don't introduce variables (even temporarily) that I don't really need. I think that clarifies the code. But putting the code in a separate function also avoids introducing those variables to the current scope only at a cost of putting the code somewhere else (which I personally think has a cost). In this case I would just use a function or (probably) just inline it as you don't like.
- tomn 3y ago> which I personally think has a cost Yeah, so many people don't get this, but too many small functions can be hard to understand -- that's why I qualified that option. In this case i agree that inlining it is fine, i was talking about the general pattern.