2011/3/17 Rick Harris <email address hidden>:
>> 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):`.
I think you're missing my point. I'm using len() to ensure it's
actually a sequence and not just something else that happens to
evaluate to True. Hmmm.. Come to think of it, I guess I'm screwed
either way. If it's not a sequence, len() will just blow up instead of
the attempt to index into it. /me fixes :)
2011/3/17 Rick Harris <email address hidden>:
>> 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):`.
I think you're missing my point. I'm using len() to ensure it's
actually a sequence and not just something else that happens to
evaluate to True. Hmmm.. Come to think of it, I guess I'm screwed
either way. If it's not a sequence, len() will just blow up instead of
the attempt to index into it. /me fixes :)
-- linux2go. dk/ www.ubuntu. com/ www.openstack. org/
Soren Hansen | http://
Ubuntu Developer | http://
OpenStack Developer | http://