[b]"How to Run a Python Program with Warnings Without Ignoring Them?"[/b] or [b]"Best Way to Handle Warnings When

20 Replies, 955 Views

If you wanna python run program with warnings *and* log ‘em, check out `warnings.filterwarnings("always")` combined with `logging`.

Here’s a quick snippet:
```python
import logging
import warnings
logging.basicConfig(filename='warnings.log', level=logging.WARNING)
warnings.filterwarnings("always")
```
Now they’re all in a neat file.

Messages In This Thread



Users browsing this thread: 1 Guest(s)