[b]"Python: how to identify error location – any tips for quickly finding where things went wrong?"[/b] or [b]"Str

16 Replies, 1368 Views

For Python: how to identify error location, I swear by `logging` over `print()`.

Set up a basic logger:
```python
import logging
logging.basicConfig(level=logging.DEBUG)
```

Then sprinkle `logging.debug("Got here with value: %s", variable)` in your code. It’s cleaner and you can toggle it off later.

Also, `python -m trace --trace script.py` gives a line-by-line execution trace. Super verbose but great for tricky bugs.

Messages In This Thread



Users browsing this thread: 1 Guest(s)