Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-02 Thread Mario Garcia
This could be better: >>> import random >>> population = range(10) >>> choice = random.choice(population) >>> population.remove(choice) >>> print population >>> print population [0, 1, 2, 3, 4, 5, 6, 8, 9] That was my idea with the previous pop(), remove from the population a certain number of

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Mario Garcia
Thank you all for your input, Yes random is what I need!! I checked the docs, and follow your comments, I will use both random.sample and random.shuffle,and random.choice etc. !! For this particular problem I think ramdom.shuffle() is what I need. I was not very clear or complete in my explanati

Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Mario Garcia
Im trying to use sets for doing statistics from a data set. I want to select, 70% random records from a List. I thougth set where a good idea so I tested this way: c = set(range(1000)) for d in range(1000): print c.pop() I was hoping to see a print out of random selected numbers from 1 to 10