You must log in or register to comment.
I think the explicitness of checking length is worth the performance cost. If ur writing code for speed ur not using python.
In complex cases where speed is less important than maintainability, I tend to agree.
In this case, a simple comment would suffice. And in fact nothing at all would be okay for any half-competent Python cover, as testing if lists are empty with
if not
is super-standard.I’d argue that if it’s strict explicitness you want, python is the wrong language.
if not var
is a standard pattern in python. You would be making your code slower for no good reason.You always want explicitness when programming. Not everyone reading your code will be deep into Python and relying on falsiness makes it harder to understand.