generated. For example, a sequence of length 2080 is the largest that
can fit within the period of the Mersenne Twister random number generator.
+ .. deprecated-removed:: 3.9 3.11
+ The optional parameter *random*.
+
.. function:: sample(population, k)
j = randbelow(i+1)
x[i], x[j] = x[j], x[i]
else:
+ _warn('The *random* parameter to shuffle() has been deprecated\n'
+ 'since Python 3.9 and will be removed in a subsequent '
+ 'version.',
+ DeprecationWarning, 2)
_int = int
for i in reversed(range(1, len(x))):
# pick an element in x[:i+1] with which to exchange x[i]
shuffle = self.gen.shuffle
mock_random = unittest.mock.Mock(return_value=0.5)
seq = bytearray(b'abcdefghijk')
- shuffle(seq, mock_random)
+ with self.assertWarns(DeprecationWarning):
+ shuffle(seq, mock_random)
mock_random.assert_called_with()
def test_choice(self):
--- /dev/null
+Deprecated the optional *random* argument to *random.shuffle()*.