[IronPython] mapping C# iterators to Python iterator

amit regmi.amit at gmail.com
Sun Dec 2 01:15:05 CET 2007


Hi,

I want to know how the "Iterators" in C# can be mapped to those in Python.
What I tried was:

say for ArrayList object
   
    def __iter__(self):
        self.index = self.Count
        return self

    def next(self):
        if self.index == 0:
            raise StopIteration
        self.index = self.index - 1
        return ??

If I am creating python classes dynamically how would I map  
GetEnumerator() , MoveNext() , Current() , Reset()
to python Class so as to make it iterable inside python.

--Regmee





More information about the Ironpython-users mailing list