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

Add a comment to make the traceback less mysterious.
This commit is contained in:
Raymond Hettinger 2004-06-05 14:53:22 +00:00
parent ba8b6bc86f
commit 9021c95595
1 changed files with 1 additions and 1 deletions

View File

@ -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.