[Edu-sig] Python error messages

Mikael Johansson mpjohans@pcu.helsinki.fi
Tue, 15 Feb 2000 14:58:34 +0200 (EET)

On Tue, 15 Feb 2000, Guido van Rossum wrote in a reply to me:

> > Anyway, the biggest problem the students seem to have when programming on
> > their own, is to find their programming errors (bugs). And almost everyone
> > has said that the error messages Python produces are cryptic. And I must
> > agree, they are not that descriptive. So better error messages would be a
> > very good way to make the learning process even easier, without
> > compromising any compatibility with earlier code.
> Mikael,
> This is good information.  It would be even better if you could recall
> and post some examples of code written by students that elicited
> cryptic (in their eyes) error messages.  Do you have any examples?
> Even if you have to reconstruct samples from memory it would be
> helpful!

Well, this is fresh in mind from yesterday:

T=500 # Temperature (K)
l=350 # Wavelength (nm)

in the above example h, c and k have their normal SI-values.

Anyway, this produces a "OverflowError: integer pow()" which can be quite
misleading when there is no pow() on the line (** instead). Other overflow
errors like "math range error" can also be hard to get.  (For the
interested: The error in the above code was to give the wavelength in nm,
instead of m, and the code calulates the energy density at a
given temp and wavelength for black-body radiation according to the
Planck distribution function)

The "best" example from yesterday was however "number coercion
failed" which I was unable to reproduce right now, don't remember what
needed to be fixed.

Other common comfusing error messages state that there is something wrong
with a line of code when in fact the error is somewhere else, like on the
preceding line.

There are more (and even better) examples, but my memory is, sad enough,
exactly what it used to be :-) I'll post more when I have something to

Have a nice day,
    Mikael J.