summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/random.py b/Lib/random.py
index f94616e..22dcb4d 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -366,7 +366,10 @@ class Random(_random.Random):
def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
- if not seq:
+
+ # As an accommodation for NumPy, we don't use "if not seq"
+ # because bool(numpy.array()) raises a ValueError.
+ if not len(seq):
raise IndexError('Cannot choose from an empty sequence')
return seq[self._randbelow(len(seq))]