When is an exception not an exception? Using warnings in Python
summary
Shows concrete APIs and behaviors: uses warnings.warn with categories and stacklevel to point to the caller, explains built-in categories and why deprecation warnings are ignored by default, demos command-line -W / PYTHONWARNINGS to alter actions (always, ignore, error) and why custom warning classes require runtime filters, walks through warnings.filterwarnings and the catch_warnings context manager, and gives real examples (pandas SettingWithCopy and deprecation transition) so it’s practical rather than conceptual.
AI-written summary · about
chapters (10)
- 0:00Introduction to warnings
- 2:20History and purpose
- 3:51Warnings vs exceptions
- 6:11How to use warnings
- 9:15Planning for change
- 10:33Warning categories
- 12:35Filtering warnings
- 15:32Advanced filtering options
- 19:17Controlling in code
- 21:06Best practices and examples
related talks
43mIntroducing incompatible changes in Python
36mHonestly It’s Easier to Ask Forgiveness Than Permission
31mGuardrails: An Alternative View of Safely Working in Python
51mIt Really is Easier to Ask for Forgiveness (than Permission)
25mNotes, Groups and Stars: exceptional new features of Python 3.11!
46mOn Being Pythonic
31mGuardrails: An Alternative View of Safely Working in Python
12mType Annotations in Python: Terribly Intimidating or Tremendously Informative?
