mirror of
https://github.com/python/cpython.git
synced 2025-08-25 03:04:55 +00:00
Implement and apply PEP 322, reverse iteration
This commit is contained in:
parent
f607fc5395
commit
85c20a41df
12 changed files with 198 additions and 9 deletions
|
@ -253,7 +253,7 @@ class Random(_random.Random):
|
|||
|
||||
if random is None:
|
||||
random = self.random
|
||||
for i in xrange(len(x)-1, 0, -1):
|
||||
for i in reversed(xrange(1, len(x))):
|
||||
# pick an element in x[:i+1] with which to exchange x[i]
|
||||
j = int(random() * (i+1))
|
||||
x[i], x[j] = x[j], x[i]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue