I think the answer is that it will always work - according to Python docs:
__len__(self):
Called to implement the built-in len () function. Should return the length of the object, an integer> = 0. In addition, an object that does not define the __nonzero__() method and the __len__() method returns zero, is considered logical in a Boolean context.
Andrew Jaffe Jan 30 '09 at 16:03 2009-01-30 16:03
source share