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

16 Replies, 1490 Views

Python: how to identify error location? Honestly, I just use `print()` but in a smarter way.

Instead of dumping random values, I label them like `print("DEBUG - line 42, x is:", x)`. Makes it easier to grep through later.

But if you want something fancier, `icecream` (`pip install icecream`) is a game-changer. Just `ic(variable)` and it prints the variable name *and* value.

Also, `%debug` in IPython after an error drops you into a post-mortem debugger. Magic.

Messages In This Thread



Users browsing this thread: 1 Guest(s)