DeprecationWarning
Built-in ExceptionPython 2.0+Intermediate
Warning about features to be removed in future versions
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
# Triggering and catching DeprecationWarning try: import warnings; warnings.warn("deprecated", DeprecationWarning) except DeprecationWarning as e: print(f"Caught DeprecationWarning: {e}") print(f"Type: {type(e).__name__}")
DeprecationWarning is raised when warning about features to be removed in future versions. Always catch specific exceptions rather than bare except clauses.
Try in PlaygroundTags
exceptionerror-handlingcore