how to suppress the "source code echo" output by warnings.warn("x")?

funkyj funkyj at gmail.com
Fri May 19 19:19:51 CEST 2006


I've been googling around trying to find the answer to this question
but all I've managed to turn up is a 2 year old post of someone else
asking the same question (no answer though).

http://groups.google.com/group/comp.lang.python/browse_frm/thread/8004c690b8c4db53/81e460a0ee8b03a5?lnk=st&q=python+warnings+echo&rnum=6#81e460a0ee8b03a5

jh> In the following
jh>
jh> import warnings
jh> warnings.warn('change me')
jh>
jh> The warning is issued:
jh>
jh> hunter:~/python/test> python test.py
jh> test.py:3: UserWarning: change me
jh>   warnings.warn('change me')
jh>
jh> I want to supress the line echo.  Eg, I just want
jh>
jh> hunter:~/python/test> python test.py
jh> test.py:3: UserWarning: change me
jh>
jh> How do I configure warnings to do this?

Perhaps this can't be done without rewriting the warning module?




More information about the Python-list mailing list