Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49362 > unrolled thread
| Started by | John Reid <j.reid@mail.cryst.bbk.ac.uk> |
|---|---|
| First post | 2013-06-28 07:14 +0100 |
| Last post | 2013-06-28 07:14 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
warnings filters for varying message John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-06-28 07:14 +0100
| From | John Reid <j.reid@mail.cryst.bbk.ac.uk> |
|---|---|
| Date | 2013-06-28 07:14 +0100 |
| Subject | warnings 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.
Back to top | Article view | comp.lang.python
csiph-web