message[, category[, stacklevel]]) |
message.__class__
will be used.
In this case the message text will be str(message)
. This function
raises an exception if the particular warning issued is changed
into an error by the warnings filter see above. The stacklevel
argument can be used by wrapper functions written in Python, like
this:
def deprecation(message): warnings.warn(message, DeprecationWarning, stacklevel=2)
This makes the warning refer to deprecation()'s caller, rather than to the source of deprecation() itself (since the latter would defeat the purpose of the warning message).
message, category, filename, lineno[, module[, registry[, module_globals]]]) |
__warningregistry__
dictionary of
the module). The module name defaults to the filename with .py
stripped; if no registry is passed, the warning is never suppressed.
message must be a string and category a subclass of
Warning or message may be a Warning instance,
in which case category will be ignored.
module_globals, if supplied, should be the global namespace in use by the code for which the warning is issued. (This argument is used to support displaying source for modules found in zipfiles or other non-filesystem import sources, and was added in Python 2.5.)
message, category, filename, lineno[, file]) |
formatwarning(message, category, filename,
lineno)
and writes the resulting string to file, which
defaults to sys.stderr
. You may replace this function with an
alternative implementation by assigning to
warnings.showwarning
.
message, category, filename, lineno) |
action[, message[, category[, module[, lineno[, append]]]]]) |
action[, category[, lineno[, append]]]) |
) |