def online_choice(iterable):
    for n, x in enumerate(iterable, 1):
        if random.randrange(n) == 0:
            pick = x
return pick
Randomly selecting a file from a tree of directories in a completely fair manner