On this page
warnings.showwarning
Prev: warnings.resetwarnings | Up: warnings | Next: warnings.simplefilter
Rel: warnings.catch_warnings, warnings.deprecated, warnings.filterwarnings, warnings.formatwarning
Ref: docs.python.org — warnings.showwarning
Tags: #public #python3 #stdlib #warnings
Import
import warnings
from warnings import showwarning
Signature & Overview
warnings.showwarning(message, category, filename, lineno, file=None, line=None)
Hook to write a warning to a file; replace if you like.
Usage
import warnings
# Hook invoked whenever a warning is not filtered out (defaults to writing to sys.stderr)
assert callable(warnings.showwarning)
Gotchas
- For routing warnings into
logging, uselogging.captureWarnings(True)instead of patchingshowwarning.
REPL Inspect
from warnings import showwarning
help(showwarning)
Linked from
Related notes
- tuts/python3/stdlib_module/warnings/resetwarnings Linked here; links to this page; shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/simplefilter 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/warn shared tags: #stdlib, #warnings
- tuts/python3/stdlib_module/warnings/warn_explicit shared tags: #stdlib, #warnings
- tuts/c/stdlib shared tags: #stdlib