[Tutor] Terminology question
Ben Finney
ben+python at benfinney.id.au
Fri May 15 02:00:06 CEST 2015
"Jim Mooney Py3.4.3winXP" <cybervigilante at gmail.com> writes:
> I noticed that if I call a function that throws an error
(Known in Python as “raise an exception”. I understood you, but it's
better to use the terminology that matches what the Python docs say.)
> I can catch it from the caller, instead of catching it in the
> function. Is this is what is known as "errors bubbling up?" Also, is
> this how you're supposed to do it?
Yes, the “call stack” (the stack of function calls waiting for execution
to return to them) can be thought of as a vertical stack through which
an exception will “bubble up”.
You should allow exceptions to bubble up to a point where they can be
handled sensibly.
Conversely, you should only ever catch a (type of) excption that you
will be able to handle sensibly at that point, otherwise allow it to
continue up the stack.
--
\ “It's all in the mind, you know.” —The Goon Show |
`\ |
_o__) |
Ben Finney
More information about the Tutor
mailing list