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

Ram Rachum report at bugs.python.org
Thu Jul 3 23:39:19 CEST 2014


Ram Rachum added the comment:

Raymond: I do take your point about performance, and I understand that if this results in a performance problem, then that's a good argument to not include this feature.

But I'm baffled as to why you're asking me regarding this feature "Why? Is there any known use case?" 

Why do we have an exception text like "TypeError: f() takes 1 positional argument but 3 were given" instead of "TypeError: f() takes a different number of arguments than you tried to give it"? Why do we have "ImportError: No module named 'foobas'" instead of "ImportError: No such module"? Do I need to spell out the reason and all the different scenario in which these exception text are super useful?

Why does an operation like `{}[42]` result in `KeyError: 42` instead of `KeyError: Key doesn't exist"? And now that I think about it, KeyError is used for control flow too, so why is it okay for it to contain the value, but on `IndexError` it's a no-no?

----------

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


More information about the Python-bugs-list mailing list