Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Issuing warnings instead of exceptions


The Python warnings module handles a special subclass of exceptions. We can use the warnings module to identify potential problems in our application. The warnings module is used internally to track a number of internal considerations.

The warning concept fits into the middle ground between perfectly normal operations and erroneous conditions. Our program may not be performing optimally, but it's not completely broken, either.

There are three notable warning classes that we might encounter when running unit tests. Since the unit test framework displays all warnings, we may see some warnings in a test context that we don't see in the normal operational use of our software.

  • DeprecationWarning: This warning is raised by modules, functions, or classes that have been deprecated. It's a reminder that we need to fix our code to stop using this feature.

  • PendingDeprecationWarning: A function, module or class for which deprecation has been announced may raise this...