Skip to content

Commit 81e682f

Browse files
committed
Remove dependency on previous recipe
1 parent 36b705f commit 81e682f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/library/random.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,11 @@ or the :pypi:`more-itertools` project:
667667
seq = tuple(iterable)
668668
if len(seq) < 2:
669669
raise ValueError('derangments require at least two values')
670+
perm = list(seq)
670671
while True:
671-
perm = random_permutation(seq)
672+
random.shuffle(perm)
672673
if all(p != q for p, q in zip(seq, perm)):
673-
return perm
674+
return tuple(perm)
674675

675676
The default :func:`.random` returns multiples of 2⁻⁵³ in the range
676677
*0.0 ≤ x < 1.0*. All such numbers are evenly spaced and are exactly

0 commit comments

Comments
 (0)