help with warning formatting

Mike Brown mike at
Thu Feb 6 20:59:46 CET 2003

"Peter Hansen" <peter at> wrote
> [RTFM, essentially]

Thanks. Before posting, I had looked at the docs and had experimented with
formatwarning(), but didn't get the results I wanted. However, I think I
figured it out now. It would have been nice if the docs were more clear
about how the default output is generated.

The answer I was looking for was either a simple example, or the explanation
"The warning module docs don't clearly say this, but the output of warn() is
governed by a combination of formatwarning(), which by default prepends the
filename and line number to the message, and showwarning(), which by default
calls formatwarning() and then appends the offending line from the call
stack. You can replace these functions with your own by reassigning them."

More information about the Python-list mailing list