Steven D'Aprano <[EMAIL PROTECTED]> writes:
> e.g. you would do this: random.sample(xrange(10**10), 60)
> except it raises an exception.

For a population that large and a sample that small (less than
sqrt(population size), the chance of collision is fairly small, so you
can just discard duplicates.

This relies on Python 2.4's randrange function to generate arbitrarily
large ranges, which in turn relies on having getrandbits (new 2.4
feature, thanks Ray) available:

    samp = Set()
    while len(samp) < 60:
       samp.add(random.randrange(10**10))
    
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to