[Python-ideas] (no subject)

Rob Cliffe rob.cliffe at btinternet.com
Tue Nov 29 11:32:05 EST 2016



On 29/11/2016 04:58, victor rajewski wrote:
>
> Traceback (most recent call last):
>
>  File "foo.py", line 2, in <module>
>
>    l[10]=14
>
> IndexError: list assignment index out of range
>
>
> A better message might be:
>
> You tried to use l[10] when l is only 4 elements long. You can add 
> items to l using l.append(value), or check your index value to make 
> sure that's really the position you wanted to access.
>
>
>
It would make sense to me to upgrade this particular error message to
IndexError: list assignment index 10 out of range 0 to 3 if it can be 
done without too much difficulty or overhead.  (An empty list, and 
perhaps one with only 1 element, would be special cases.)  Come to think 
of it, is the word "assignment" needed?
Rob Cliffe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161129/eb9f9e0e/attachment.html>


More information about the Python-ideas mailing list