[issue44166] Make IndexError messages for list more informative

Raymond Hettinger report at bugs.python.org
Sun Dec 5 16:17:35 EST 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

I also share Serhiy's concerns and prefer that it be left as-is.

Conceptually, adding more information in the error message would make it more useful for debugging, but in practice, it would rarely be helpful.  In teaching and coaching Python, I've learned that the intended, dominant effect of seeing "IndexError: list index out of range" is that a person understands that index is invalid because it is out of range.  That is a helpful dominant impression.  IMO it would be distracting and rarely helpful to focus on the specific index and length.  The important point is that a nonsense lookup was being made.

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44166>
_______________________________________


More information about the Python-bugs-list mailing list