[issue21911] "IndexError: tuple index out of range" should include the requested index and tuple length

Ram Rachum report at bugs.python.org
Fri Jul 4 00:30:47 CEST 2014


Ram Rachum added the comment:

Josh... The reason I gave all these examples of where Python gives detailed error messages, is not so you'd explain the obvious reason, which is that it makes it easier to debug, figure out what's wrong with your program, and fix it. The reason I gave these examples is that I'm baffled by this attitude that I see all the time on python-dev, where people are asking me questions when the answers are obvious to all of us.

I suggested adding more information to the "IndexError: tuple index out of range", like "IndexError: tuple only has 4 elements, can't access element number 7." It should be obvious to any programming novice why this is helpful: Because it makes it much easier to figure out what your program is doing wrong, so you could fix it. (I feel silly having to spell it out in company of so many experienced developers who all understand this basic fact.)

I'm very frustrated that a core Python developer would ask me "Why?  Is there any known use case?" on such a no-brainer suggestion.

Now, if you want to make the performance argument, that's acceptable. But it's very, very frustrating that people on python-dev, who are very experienced developers, need to be explained the virtue of very simple and obvious features. (This happens many times, not just on this ticket.) I'm baffled as to why they do this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21911>
_______________________________________


More information about the Python-bugs-list mailing list