From: Raymond Hettinger Date: Sat, 5 Jun 2004 14:53:22 +0000 (+0000) Subject: SF bug #964230: random.choice([]) should return more intelligible exception X-Git-Tag: v2.4a1~261 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9021c955951c63ef3075b4751615af329427d3ec;p=python SF bug #964230: random.choice([]) should return more intelligible exception Add a comment to make the traceback less mysterious. --- diff --git a/Lib/random.py b/Lib/random.py index 58865fc59b..92163bb608 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -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.