summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 99ae750..075c3b7 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -256,7 +256,7 @@ class Random(_random.Random):
if random is None:
random = self.random
- for i in reversed(xrange(1, len(x))):
+ for i in reversed(range(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]
@@ -274,9 +274,9 @@ class Random(_random.Random):
population contains repeats, then each occurrence is a possible
selection in the sample.
- To choose a sample in a range of integers, use xrange as an argument.
+ To choose a sample in a range of integers, use range as an argument.
This is especially fast and space efficient for sampling from a
- large population: sample(xrange(10000000), 60)
+ large population: sample(range(10000000), 60)
"""
# XXX Although the documentation says `population` is "a sequence",
@@ -311,7 +311,7 @@ class Random(_random.Random):
# An n-length list is smaller than a k-length set, or this is a
# mapping type so the other algorithm wouldn't work.
pool = list(population)
- for i in xrange(k): # invariant: non-selected at [0,n-i)
+ for i in range(k): # invariant: non-selected at [0,n-i)
j = _int(random() * (n-i))
result[i] = pool[j]
pool[j] = pool[n-i-1] # move non-selected item into vacancy
@@ -319,7 +319,7 @@ class Random(_random.Random):
try:
selected = set()
selected_add = selected.add
- for i in xrange(k):
+ for i in range(k):
j = _int(random() * n)
while j in selected:
j = _int(random() * n)