Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49362 > unrolled thread

warnings filters for varying message

Started byJohn Reid <j.reid@mail.cryst.bbk.ac.uk>
First post2013-06-28 07:14 +0100
Last post2013-06-28 07:14 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  warnings filters for varying message John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-06-28 07:14 +0100

#49362 — warnings filters for varying message

FromJohn Reid <j.reid@mail.cryst.bbk.ac.uk>
Date2013-06-28 07:14 +0100
Subjectwarnings filters for varying message
Message-ID<mailman.3951.1372400088.3114.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web