[Python-ideas] Shuffled

Arek Bulski arek.bulski at gmail.com
Tue Sep 6 11:29:18 EDT 2016


> And if random.shuffle() returned a new list, other people would be bitten
because they expected it to be in-place.

No one proposes that. shuffled() should be a new function.

> One moderately stong piece of evidence would be if this function is widely
available in third-party libraries and other languages.

Wrong. Python is NOT known for doing everything by how it was done before.
My father used statically typed variables and his father used statically
typed variables so I will use...

> If so, then I would suggest than each list provides a .shuffle method as well
(just as sorted/sort does).

Well, that could be problematic because std lib would have to use a random
generator. We should leave things that require a source of randomness
somewhere in the random module. Would you agree on that?


Randomized unit testing is obvious example. Besides, any argument that can
be used for having shuffle() could be also made for adding shuffled().
Randomizing lists has been used for a long time. We only need an non
mutating analog.

I am willing to make a patch.


pozdrawiam,
Arkadiusz Bulski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160906/2d1ab06b/attachment.html>


More information about the Python-ideas mailing list