Sorry, I forgot the subject line!

On Tue., 29 Nov. 2016, 3:58 pm victor rajewski, <askvic...@gmail.com> wrote:

> I teach a computing subject to high school students using Python as our
> primary language. One thing that often causes confusion at the start is
> error messages/exceptions. I think it would lower entry point quite a bit
> by making error messages more readable to novices. Recent research found
> reduced frequency of overall errors, errors per student, and repeated
> errors when error messages were enhanced [1].
>
> This could be implemented by a command-line switch when running python, or
> a different python executable (along the lines of pythonw.exe vs
> python.exe) such as python-easy. A simpler error message might get rid of
> excess information which can confuse the novice (such info might be dumped
> to a file to allow more advanced users to debug), provide a brief
> description of what the error might mean, and/or how you might fix it. So a
> SyntaxError might tell the user that they've probably forgotten a :, and a
> NameError might say that the item has been defined yet, or they've made a
> typo. A couple of examples follow:
>
> Traceback (most recent call last):
>
>  File "foo.py", line 2, in <module>
>
>    l[10]=14
>
> IndexError: list assignment index out of range
>
> A better message might be:
>
> You tried to use l[10] when l is only 4 elements long. You can add items
> to l using l.append(value), or check your index value to make sure that's
> really the position you wanted to access.
>
> Traceback (most recent call last):
>
>  File "foo.py", line 2, in <module>
>
>    while name != "quit" and reponse != "quit":
>
> NameError: name 'reponse' is not defined
>
> A better message might be:
>
> You're trying to use the value of 'reponse', but that variable hasn't got
> a value yet. You can give it a value earlier in the code, or it could be a
> typo. You have a variable called 'response' - is that the one you meant?
>
> Traceback (most recent call last):
>
>  File "foo.py", line 2, in <module>
>
>    print(length(l))
>
> NameError: name 'length' is not defined
>
> A better message might be:
>
> Python doesn't recognise the function "length". Did you mean len?'
>
>  File "foo.py", line 2
>
>    for i in l
>
>             ^
>
> SyntaxError: invalid syntax
>
> A better message might be:
>
> You have a for loop without a : (colon). Try adding a colon at the end of
> the line.
>
>
> Any thoughts?
>
> [1]: http://researchrepository.ucd.ie/handle/10197/7583
> --
>
> Victor Rajewski
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

-- 

Victor Rajewski
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to