Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is no bug in Sequence. What is happening is you are creating a foo object filled with foos. However, when you compute the size of the outer foo this will request the length of the inner foo and your current implementation of foo has no way of reporting its length. A possible workaround would be to implement the __len__ method instead of having the size method.

Or if you prefer to have them side by side:

class foo(object) :
    def __init__(self, L_) :
        self.L = deepcopy(L_)

    def __getitem__(self, j) :
        return self.L[j]

    def size(self) :
        return len(self.L)
    def __len__(self):
        return self.size()