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

warnings.formatwarning

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


Import

import warnings
from warnings import formatwarning

Signature & Overview

warnings.formatwarning(message, category, filename, lineno, line=None)

Function to format a warning the standard way.

Usage

import warnings

msg = warnings.formatwarning('old api', DeprecationWarning, 'app.py', 10)
assert 'DeprecationWarning: old api' in msg

Gotchas

REPL Inspect

from warnings import formatwarning
help(formatwarning)

Linked from

Related notes