Enhanced information from common exceptions
John Machin
sjmachin at lexicon.net
Sat Mar 16 20:01:22 EST 2002
An example:
>>> alist = [4,3,2,1]
>>> alist[42]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IndexError: list index out of range
>>>
Suppose this was actually in a script somewhere. IMO, it would be much
more useful for Python developers of all levels were the message to be
something like:
IndexError: list index 42 not in range(4)
Often this extra info would lead to problem recognition & resolution
without the need for an extra step (print statement or debugger).
Perhaps if people cared to nominate their "favourite"
high-frequency-low-information exception message(s), together with
suggested changes, we could put together a nanoPEP on this topic -- or
simply just propose a few patches.
More information about the Python-list
mailing list