def choice_gen(choices, min_dist):
    last_choices = collections.deque(maxlen=min_dist)
choices = set(choices)
while 1:
    c = random.choice(list(choices - set(last_choices)))
last_choices.append(c)
yield c
Python random.choice() function - how to never have two choices in a row or close to one another