[Python-Dev] Traceback style

Eric S. Raymond esr@thyrsus.com
Tue, 2 May 2000 06:16:55 -0400


Ka-Ping Yee <ping@lfw.org>:
> I propose the following stylistic changes to traceback
> printing:
> 
>     1.  If there is no function name for a given level
>         in the traceback, just omit the ", in ?" at the
>         end of the line.
> 
>     2.  If a given level of the traceback is in a method,
>         instead of just printing the method name, print
>         the class and the method name.
> 
>     3.  Instead of beginning each line with:
>         
>             File "foo.py", line 5
> 
>         print the line first and drop the quotes:
> 
>             Line 5 of foo.py
> 
>         In the common interactive case that the file
>         is a typed-in string, the current printout is
>         
>             File "<stdin>", line 1
>         
>         and the following is easier to read in my opinion:
> 
>             Line 1 of <stdin>
> 
> Here is an example:
> 
>     >>> class Spam:
>     ...     def eggs(self):
>     ...         return self.ham
>     ... 
>     >>> s = Spam()
>     >>> s.eggs()
>     Traceback (innermost last):
>       File "<stdin>", line 1, in ?
>       File "<stdin>", line 3, in eggs
>     AttributeError: ham
> 
> With the suggested changes, this would print as
> 
>     Traceback (innermost last):
>       Line 1 of <stdin>
>       Line 3 of <stdin>, in Spam.eggs
>     AttributeError: ham

IMHO, this is not a good idea.  Emacs users like me want traceback
labels to be *more* like C compiler error messages, not less.
-- 
		<a href="http://www.tuxedo.org/~esr">Eric S. Raymond</a>

The United States is in no way founded upon the Christian religion
	-- George Washington & John Adams, in a diplomatic message to Malta.