hekevintran hekevintran - 1 year ago 121
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download