naive question about tracebacks

Peter Hansen peter at engcorp.com
Wed Feb 19 19:02:11 EST 2003


Andrew Koenig wrote:
> 
> >>> def foo():
> ...     bar()
> ...
> >>> def bar():
> ...     baz()
> ...
> >>> foo()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<stdin>", line 2, in foo
>   File "<stdin>", line 2, in bar
> NameError: global name 'baz' is not defined
> 
> If the most recent call is last, why is it called a traceback
> instead of a traceforward?

Because it represents a history, going back in time, regardless
of the direction the items are shown.

> More generally, why is the most recent call last?  Is it because
> of the presumption that the earlier calls will scroll off the
> top of the screen?

Sounds like a very good reason.  If you don't like the order,
you should be able to install your own replacement exception
handler which calls the slightly lower level routines 
necessary to format things in the opposite direction.

-Peter




More information about the Python-list mailing list