class MyContainer(Iterator):

    def __init__(self, *data):
        self.data = list(data)

def next(self):
    if not self.data:
        raise StopIteration
return self.data.pop()
c = MyContainer(1, 'two', 3, 4.0)
for i in c:
    pass
How to implement __iter__(self) for a container object (Python)