summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 7210f62..2530c39 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -258,6 +258,10 @@ class Random(_random.Random):
result[i] = pool[j]
pool[j] = pool[n-i-1] # move non-selected item into vacancy
else:
+ try:
+ n > 0 and (population[0], population[n//2], population[n-1])
+ except (TypeError, KeyError): # handle sets and dictionaries
+ population = tuple(population)
selected = {}
for i in xrange(k):
j = _int(random() * n)