> The reasoning was that I'm not just referencing it afterwards, I'm specifically indexing into it.
> To ensure that that is a valid operation, it needs to have a non-zero length, not just be any value
> that evaluates to True.
Sure. Since you're indexing into the object, it's guaranteed to be a sequence. Sequences evaluate to truthy iff it has at least one element, so `if seq:` is just as safe as `if len(seq):`.
The only difference is, the former is Pep-8 and a constant-time operation.
`len(seq)` really only makes sense if you're comparing to a value > 0, or if you're re-using it in a later operation.
That said, it's obviously not a big deal, so, I'll leave to your discretion whether to 'fix'. :)
> The reasoning was that I'm not just referencing it afterwards, I'm specifically indexing into it.
> To ensure that that is a valid operation, it needs to have a non-zero length, not just be any value
> that evaluates to True.
Sure. Since you're indexing into the object, it's guaranteed to be a sequence. Sequences evaluate to truthy iff it has at least one element, so `if seq:` is just as safe as `if len(seq):`.
The only difference is, the former is Pep-8 and a constant-time operation.
`len(seq)` really only makes sense if you're comparing to a value > 0, or if you're re-using it in a later operation.
That said, it's obviously not a big deal, so, I'll leave to your discretion whether to 'fix'. :)