On this page
  1. warnings.filterwarnings
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from warnings import filterwarnings
help(filterwarnings)

Linked from

Related notes