[Tutor] try..except - what about that ton of **Error statements?

boB Stepp robertvstepp at gmail.com
Wed May 22 18:09:14 CEST 2013


Thanks, Steve, for your last two posts. You have made things much
clearer for me.

On Wed, May 22, 2013 at 9:49 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 22/05/13 23:37, boB Stepp wrote:
>>
>> On Wed, May 22, 2013 at 8:07 AM, Steven D'Aprano <steve at pearwood.info>
>> wrote:
>>>

[...]

>>
>> Being a novice programmer, I am interpreting this to mean that a) I
>> complete a program. b) I believe it to be correct and bug-free. c) I
>> should make sure I do NOT try to catch errors just to keep the program
>> running from things I failed to anticipate (Probably from being a
>> novice programmer!). So the conclusion I am drawing is that I WANT my
>> program to crash if something I did not anticipate/plan for happens.
>> Am I understanding this correctly?
>
>
>
> Yes!
>
>
> Well, within reason. If you are programming in C, a crash can be a nasty
> thing to deal with. It could cause memory corruption, leading to a Blue
> Screen of Death or equivalent. In the absolute worst case, low-level C or
> assembly bugs can actually cause hardware damage! So you don't want to be
> writing low-level code like that if you can avoid it.
>

I was not aware that hardware damage could be caused by poor
programming. I am curious; can you give some examples of how this
might occur?

> But in a high-level language like Python, exceptions are not to be feared.
> They are perfectly safe, and should be welcomed, since they show you where
> your code needs to be improved.
>
I would like to ask some general questions here. Problems can arise
from bugs in the operating system, bugs in the programming language(s)
being used, bugs in packages/modules being used, bugs in any third
party packages being used, etc. Also, whenever any one of these things
is updated/upgraded, it can introduce new issues. What strategies can
one use to deal with these possibilities that seem entirely out of the
programmer's control?

boB


More information about the Tutor mailing list