News for hackers. Stuff that matters.
Re:Advanced Python Mastery – A Course by David Beazley by CogitoCogito on Wednesday July 19, 2023 @01:22PM (#36789957)
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.
Re:Advanced Python Mastery – A Course by David Beazley by tomn on Wednesday July 19, 2023 @04:39PM (#36792936)
> 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.