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

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Jul 1 21:28:19 EDT 2009


On Wed, 01 Jul 2009 17:49:21 -0700, Paul Rubin wrote:

> Carl Banks <pavlovevidence at gmail.com> writes:
>> Instead, call random.shuffle() on the list, and iterate through that to
>> get the elements in random order.
> 
> It's better to use random.sample() than random.shuffle().

Why?


-- 
Steven



More information about the Python-list mailing list