warnings filters for varying message
John Reid
j.reid at mail.cryst.bbk.ac.uk
Fri Jun 28 02:14:35 EDT 2013
Looking at the docs for warnings.simplefilter
(http://docs.python.org/2/library/warnings.html) I think the following
script should only produce one warning at each line as any message is
matched by the simple filter
import warnings
warnings.simplefilter('default')
for i in xrange(2):
warnings.warn('Warning message') # This prints 1 warning
warnings.warn("Warning %d" % i) # This prints 2 warnings
What do I need to do to get the warnings module just to print one
warning for the second warnings.warn line?
Thanks,
John.
More information about the Python-list
mailing list