Trying to use sets for random selection, but the pop() method returns items in order
Thu Jul 2 03:37:38 CEST 2009
Carl Banks <pavlovevidence at gmail.com> writes:
> If you're iterating through the whole list and don't need to preserve
> the original order (as was the case here) random.shuffle() is better.
1. Random.sample avoids iterating through the whole list when it can.
2. Say you want to choose 10 random numbers between 1 and 1000000.
works nicely. Doing the same with shuffle is painful.
More information about the Python-list