Commit 9021c955 authored by Raymond Hettinger's avatar Raymond Hettinger

SF bug #964230: random.choice([]) should return more intelligible exception

Add a comment to make the traceback less mysterious.
parent ba8b6bc8
......@@ -237,7 +237,7 @@ class Random(_random.Random):
def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
return seq[int(self.random() * len(seq))]
return seq[int(self.random() * len(seq))] # raises IndexError in seq is empty
def shuffle(self, x, random=None, int=int):
"""x, random=random.random -> shuffle list x in place; return None.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment