Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your class must implement an __iter__ method:

class Foo(SageObject):

    def __iter__(self):
        for i in range(10):
            yield(i)

Then you can just say:

sage: bar = Foo()
sage: list(bar)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]