def __len__(self):
        res = 0
        for l, h in self.ranges:
            if l is None:
                if h is None:
                    res += 1
                else:
                    raise TypeError("Can't size object; last value not set")
            else:
                res += (h - l) + 1

        return res
dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/mail/imap4.py/MessageSet.__len__/original