Nice to know about random.sample! =)

I think what OP said can then be reduced to having the default k in random.sample to be the iterable size. The existance of random.sample is a very strong argument against "shuffled", and the only "feature" shuffled would have that random.sample doesn't have is that default size.

You cannot sort a sequence lazily
You can, but it probably wouldn't be efficient if you need all the values. On the other hand, if you need just the 3 smaller values of a huge list... well, that's another topic.


2016-09-08 0:28 GMT-03:00 Nick Coghlan <ncoghlan@gmail.com>:
On 8 September 2016 at 13:23, Nick Coghlan <ncoghlan@gmail.com> wrote:

> Beyond that practical benefit, if you want
> random-sampling-with-replacement, then "map(random.choice, container)"

Oops, that was supposed to be "map(random.choice, itertools.repeat(container))".

Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia



--
Danilo J. S. Bellini
---------------
"It is not our business to set up prohibitions, but to arrive at conventions." (R. Carnap)