help with warning formatting
peter at engcorp.com
Thu Feb 6 19:40:55 CET 2003
Mike Brown wrote:
> I'm trying to get the hang of warnings.
> % cat t.py
> import warnings
> % python t.py
> t.py:2: UserWarning: foo
> Is there a way to just issue the warning message itself, or to at least
> suppress printing the line where the warning occurred ("
> warnings.warn('foo')" in the example)?
> See, I want to warn the user of my application that they're doing something
> risky or improper, so I just want to emit the 'foo', subject to the usual
> determination of whether the warning needs to be printed at all. For my
> purposes, the user doesn't need to know where the warning occurred, and they
> certainly don't need to see pieces of the call stack.
The documentation for the warning module tells you how to change the
formatting of the output...
More information about the Python-list