Carl Banks <pavlovevide...@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.

   random.sample(xrange(1000000), 10)

works nicely.  Doing the same with shuffle is painful.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to