import random def shuffle_gen(l): while l: yield l.pop(random.randint(0, len(l)-1))