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

warnings.warn_explicit

Prev: warnings.warn | Up: warnings
Rel: warnings.catch_warnings, warnings.deprecated, warnings.filterwarnings, warnings.formatwarning
Ref: docs.python.org — warnings.warn_explicit
Tags: #public #python3 #stdlib #warnings


Import

import warnings
from warnings import warn_explicit

Signature & Overview

warnings.warn_explicit(...)

Issue a warning, or maybe ignore it or raise an exception.

Usage

import warnings

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter('always')
    warnings.warn_explicit('msg', UserWarning, 'virtual.py', 1)
assert caught[0].filename == 'virtual.py'

Gotchas

REPL Inspect

from warnings import warn_explicit
help(warn_explicit)

Linked from

Related notes