hekevintran hekevintran - 5 months ago 43
Python Question

Python warnings.warn() vs. logging.warning()

What is the difference between warnings.warn() and logging.warn() in terms of what they do and how they should be used?


One raises an exception which can be caught or ignored as desired, and the other optionally adds an entry to the log based on the current logging level. One should be used when one is warning about various things in code, and the other should be used when logging.