class Foo: def __len__(self): return -1
class Foo: def __len__(self): return 0 # n >= 0
Used when a __len__ method returns something which is not a non-negative integer.
__len__