On this page
warnings.simplefilter
Prev: warnings.showwarning | Up: warnings | Next: warnings.warn
Rel: warnings.catch_warnings, warnings.deprecated, warnings.filterwarnings, warnings.formatwarning
Ref: docs.python.org — warnings.simplefilter
Tags: #public #python3 #stdlib #warnings
Import
import warnings
from warnings import simplefilter
Signature & Overview
warnings.simplefilter(action, category=<class 'Warning'>, lineno=0, append=False)
Insert a simple entry into the list of warnings filters (at the front).
Usage
import warnings
with warnings.catch_warnings():
warnings.simplefilter('error', DeprecationWarning)
try:
warnings.warn('boom', DeprecationWarning)
except DeprecationWarning:
assert True
Gotchas
- Common actions:
'error','ignore','always','default','once'.
REPL Inspect
from warnings import simplefilter
help(simplefilter)
Linked from
Related notes
- tuts/python3/stdlib_module/warnings/showwarning Linked here; links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/warn Linked here; links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/warnings/catch_warnings Linked here; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/deprecated Linked here; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/filterwarnings Linked here; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/formatwarning Linked here; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/resetwarnings shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/warn_explicit shared tags: #stdlib, #warnings
- tuts/c/stdlib shared tags: #stdlib