[Python-3000] The future of exceptions
Josiah Carlson
jcarlson at uci.edu
Sun Sep 10 20:08:41 CEST 2006
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Or maybe there should be a different mechanism altogether
> for non-local gotos. I'd like to see some kind of "longjmp"
> object that could be invoked to cause a jump back to
> a specific place. That would help alleviate the problem
> that exceptions used for control flow can get caught by
> the wrong handler. Sometimes you really want something
> that's targeted to a specific handler, not just the next
> enclosing one of some type.
I imagine you mean something like this...
try:
for ....:
try:
dosomething()
except Exception:
...
except FlowException1:
...
And the answer I've always heard is:
try:
for ....:
try:
dosomething()
except FlowException1:
raise
except Exception:
...
except FlowException1:
...
That really only works if you have control over the entire stack of
possible exception handlers, but it is also really the only way it
makes sense, unless I'm misunderstanding what you are asking for. If I
am misunderstanding, please provide some sample code showing what needs
to be done now, and what you would like to be possible.
- Josiah
More information about the Python-3000
mailing list