'Return a k-length list of unique elements chosen from the population sequence.'

def sample(self, population, k):

    num_choices = len(population)
    if (k > num_choices):
        raise ValueError('sample    larger    than    population')
    retval = []
    selected = {}
    for i in xrange(k):
        r = None
        while ((r is None) or selected.has_key(r)):
            r = self.randrange(num_choices)
        retval.append(population[r])
        selected[r] = 1
    return retval
