Here's a simple variant that will do what you want. Note that there are almost certainly much more efficient ways to do this, as this is currently O(n^2) in run time and uses n*m maximum memory where n is input population size and m is average weight, as it builds a list that has one copy of the input list value per weight.
import random
import itertools
def random_weighted_shuffle(input_population):
'''
:param input_population: {name:weight}, where weight is the 'number of chances' that this particular name will be drawn
'''
out_list = []
while input_population:
lotto_list = list(itertools.chain.from_iterable([name]*weight for name, weight in input_population.iteritems()))
selection = lotto_list[random.randint(0,len(lotto_list)-1)]
del input_population[selection]
out_list.append(selection)
return out_list
A very important note: As written, this method is destructive to the input dictionary.
Usage:
>>> random_weighted_shuffle({'a':10,'b':2,'c':5})
['a', 'b', 'c']
>>> random_weighted_shuffle({'a':10,'b':2,'c':5})
['a', 'c', 'b']
>>> random_weighted_shuffle({'a':10,'b':2,'c':5})
['b', 'c', 'a']
>>> random_weighted_shuffle({'a':10,'b':2,'c':5})
['c', 'a', 'b']
>>> random_weighted_shuffle({'a':10,'b':2,'c':5})
['a', 'c', 'b']