from random import choice class RandSeqIterator(object) : def __init__(self, seq) : self.data = seq def __iter__(self) : return self def next(self) : return choice(self.data)
for eachItem in RandSeqIterator(('AA', 'BB', 'CC', 'DD', 'End')) : print eachItem if eachItem == 'End' : break
|