warnings filters for varying message

J

John Reid

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top