[Tutor] general exception questions

richard kappler richkappler at gmail.com
Mon Oct 5 20:23:39 CEST 2015


>
>
>
> how else do you skip the current line if the 'try' can't be done, and go on
>> to the next line exiting the program with a trace error?
>>
>
> That last sentence confused me. If you use pass (or continue)
> you will NOT get any trace error. If you want to store the
> error to report it at the end then it's quite a bit more work,
> you would need something like:
>

Yup, confused myself when I reread it, sorry Alan. It should have been ..if
the 'try' can't be done, and go on to the next line INSTEAD OF exiting the
program with a trace error.

>
> errors = []
> for line in file:
>    try:
>      process(line)
>    except SomeError as e:
>       errors.append((line,e))
>
> if errors:
>    for e in errors:
>       display_error(e)
>
> where display_error() is an exercise for the student :-)
>

Interesting. Sounds like something else I need to take a round turn on.

regards, Richard


More information about the Tutor mailing list