Warning Framework

Python 2.1 introduces warnings

  • Informational messages issued at runtime
  • Primary intent is to inform users of deprecated/problematic features
     >>> import regex
     __main__:1: DeprecationWarning: the regex module is deprecated; 
     please use the re module
     >>> def foo():
     ...     def bar():
     ...         print x
     ...     exec "x = 1"
     ...
     <stdin>:1: SyntaxWarning: unqualified exec is not allowed in function
     'foo' it contains a nested function with free variables
     >>>
     
  • Unlike exceptions, control does not stop. Only a message is printed.
<<< O'Reilly OSCON 2001, New Features in Python 2, Slide 34
July 26, 2001, beazley@cs.uchicago.edu
>>>