Warning Framework

Types of Warnings

     Warning              # Base-class for all warnings
     UserWarning          # Default warning
     DeprecationWarning   # Deprecated feature
     SyntaxWarning        # Use of dubious syntax features
     RuntimeWarning       # Use of dubious runtime features
  • Each is also derived from Exception

Issuing a warning

  • warnings module
  • warn(message [, category])
     import warnings
     warnings.warn("Hey, I'm warning you...")     # UserWarning
     warnings.warn("x is deprecated, use y", DeprecationWarning)
     
<<< O'Reilly OSCON 2001, New Features in Python 2, Slide 35
July 26, 2001, beazley@cs.uchicago.edu
>>>