redirecting stdout
Gerhard Häring
gerhard.haering at gmx.de
Wed Nov 27 20:51:53 EST 2002
Marco Herrn wrote:
> Hi,
>
> I am redirecting my output to a file via:
> sys.stderr= open('out.txt','a', 0)
>
> All exceptions are handled like this:
>
> try:
> ...
> except Exception, detail:
> print detail
>
> That works. But I am missing the line numbers. How can I get to the line
> numbers in exceptions?
Check out the 'traceback' module. Here's a short example:
http://www.python.org/doc/current/lib/traceback-example.html
-- Gerhard
More information about the Python-list
mailing list