The warnings Module
Warnings are messages about errors or
anomalies that may not be serious enough to be worth disrupting the
program’s control flow (as would happen by raising a
normal exception). The warnings module offers you
fine-grained control over which warnings are output and what happens
to them. Your code can conditionally output a warning by calling
function warn in module
warnings. Other functions in the module let you
control how warnings are formatted, set their destinations, and
conditionally suppress some warnings (or transform some warnings into
exceptions).
Classes
Module warnings supplies several exception classes
representing warnings. Class Warning subclasses
Exception and is the base class for all warnings.
You may define your own warning classes; they must subclass
Warning, either directly or via one of its other
existing subclasses, which are:
-
DeprecationWarning Using deprecated features only supplied for backward compatibility
-
RuntimeWarning Using features whose semantics are error-prone
-
SyntaxWarning Using features whose syntax is error-prone
-
UserWarning Other user-defined warnings that don’t fit any of the above cases
Objects
In the current version of Python, there are no concrete warning
objects. A warning is composed of a
message (a text string), a
category (a subclass of
Warning), and two pieces of information that
identify where the warning was raised from:
module (name of the module raising the
warning) and lineno (line number of the source code ...