[Tutor] How to deal with strange errors?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri, 26 Apr 2002 10:35:15 -0700 (PDT)


> note = ziffer = durchschnitt = input = ("Wenn du fertig bist, gib 0
                                 ^^^^^^^^^

Yes.  This doesn't call the input() function at all, but rebinds all those
variables to a string.  But one question is to ask: is there a reason why
all those variables are directed to the same value?



> He got the error message:
>
> Gib jeweils eine Note ein.
> Traceback (most recent call last):
>   File "Z:\6b-20020426\spaula\notendurchschnitt.py", line 10, in ?
>     ziffer = note % 10
> TypeError: not all arguments converted


This is an error message that occurs during string formatting.  However, I
think you're right: this error message doesn't seem descriptive enough for
a newcomer to understand what's happening.  Even for an intermediate user,
this error message doesn't really mention the cause of the error, but only
the side effect of it.

It might be good to modify the error message to explicitely say something
like:

"TypeError: not all arguments converted during string formatting"

to give a better hint that 'note' here is a string.  I've entered a
feature request into Sourceforge for this.

http://sourceforge.net/tracker/index.php?func=detail&aid=549187&group_id=5470&atid=355470

and perhaps the error message itself can be improved to make the error
more clear.




> 2. How could one develop means, which makes restarting the IDE or
>    the interpreter obsolete?
>    As far as I remember there is a good example in the
>    TeachScheme-Project,
>    where language-features can be turned on/off according to the level
>    of knowledge of the students.
>    One could imagine - in the case obove - to turn off the possibility
>    of overwriting built-in functions in Python ( does there exist a
>    switch
>    concerning this?).

DrScheme will, in fact, warn the user to clear off the previous session if
a program has changed.  It even has a large RESET button with red letters
to make clearing the environment easy to do.





> 3. Is it possible to rebind input() to it's original built-in function
>    without restarting the whole machinery.

Although 'input' in the global environment is bound to that string now,
it's still possible to fix this by going through the __builtin__ module
and refix things:

###
>>> input = 'argh'
>>> input
'argh'
>>> from __builtin__ import *
>>> input
<built-in function input>
###

That's probably one way of doing it.



> 4. Is there a list somewhere of features to implement / provide for
> educational use of IDLE or some special eduactional-IDE? Or should we
> start to collect ideas in this direction?

The IDLEFork-dev mailing list might be a good place to place to discuss
educational issues with IDLE.


Good luck to you!