[Patches] indexerror: better error messages
Moshe Zadka
Moshe Zadka <moshez@math.huji.ac.il>
Sun, 11 Jun 2000 13:22:18 +0300 (IDT)
On Sun, 11 Jun 2000, Peter Schneider-Kamp wrote:
> error messages like "list index out of range" are not very
> helpful. a discussion about better error messages on the
> python mailing list proposed to add information about the
> value of the index which caused the IndexError and about
> the valid range.a few examples:
<snip>
> The speed penalty in case of a caught exception is constant
> and imho negligibly.
Did you check it? You're taking a formatting hit for every IndexError!
That doesn't seem this negligible. Why not simply have IndexError
with enough members for formatting, and do the formatting (including
the intellegient about checking if the size is 0) inside IndexError's
__str__?
--
Moshe Zadka <moshez@math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com