Beginner question. Exceptions

Jose Carlos Balderas Alberico josecarlos.balderas at gmail.com
Wed Apr 12 03:58:07 EDT 2006


Hello. I'm having my way with exceptions in a little program I've done, and
I'm wondering... What is a decent way of dealing with them? By a decent way
I mean, what should I do when I see that an exception has occurred? I've
seen that Python's default action is to print a stack trace. As far as I
know, exception handling is a mean of knowing what can go wrong with your
program, like anticipating wrongs and treating them.

What I'm having trouble understanding is this: if I use a "raise" sentence
to raise an exception... shoul I use it inside a "try" block, so I can catch
it with an "except" block? If I don't do that, a stack trace will be printed
onto the screen... Is that the way it's usually done?

Please, help me out, for I'm kind of new to exceptions and I want to know if
I get them right.

Thanks a lot in advance.
Jose Carlos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060412/a3be8710/attachment.html>


More information about the Python-list mailing list