1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
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
|