A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039398.html below:

[Python-Dev] random.choice IndexError on empty list

[Python-Dev] random.choice IndexError on empty list [Python-Dev] random.choice IndexError on empty listPete Shinners pete at shinners.org
Thu Oct 23 16:22:59 EDT 2003
(this should potentialy go on sourceforge's bug tracker? alas i have 
no account right now)

Another user and I were scratching our heads over why random.choice() 
was raising "IndexError: list index out of range". For awhile we were 
thinking random.random() must have been returning >= 1.0. It turns out 
an empty list was being passed.

I would suggest either a ValueError is raised, or a different 
exception message. perhaps more like the results of

     >>> [].pop()
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     IndexError: pop from empty list

The patch is trivial, but I can provide it if there is an agreed-apon 
response.



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4