warnings.filterwarnings
Prev: warnings.deprecated | Up: warnings | Next: warnings.formatwarning
Rel: warnings.catch_warnings, warnings.deprecated, warnings.formatwarning, warnings.resetwarnings
Ref: docs.python.org — warnings.filterwarnings
Tags: #public #python3 #stdlib #warnings
Import
import warnings
from warnings import filterwarnings
Signature & Overview
warnings.filterwarnings(action, message='', category=<class 'Warning'>, module='', lineno=0, append=False)
Insert an entry into the list of warnings filters (at the front).
Usage
import warnings
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='noisy.*', category=UserWarning)
warnings.warn('noisy warning', UserWarning)
Gotchas
- Regex match on
message=(anchored at start) andmodule=.
REPL Inspect
from warnings import filterwarnings
help(filterwarnings)
Linked from
- tuts/python3/stdlib_module/warnings
- tuts/python3/stdlib_module/warnings/catch_warnings
- tuts/python3/stdlib_module/warnings/deprecated
- tuts/python3/stdlib_module/warnings/formatwarning
- tuts/python3/stdlib_module/warnings/resetwarnings
- tuts/python3/stdlib_module/warnings/showwarning
- tuts/python3/stdlib_module/warnings/simplefilter
- tuts/python3/stdlib_module/warnings/warn
- tuts/python3/stdlib_module/warnings/warn_explicit
Related notes
- tuts/python3/stdlib_module/warnings/catch_warnings Linked here; links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/deprecated Linked here; links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/formatwarning Linked here; links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/resetwarnings 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/showwarning links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/simplefilter links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/warn links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/warn_explicit links to this page; shared tags: #stdlib, #warnings
- tuts/c/stdlib shared tags: #stdlib