Ask coding questions

← Back to all posts
How to debug or exit without clearing variables?
APLInstructorP2 (0)

Is there a way to debug python3 repls or at least a way to exit the code execution right before the error to inspect variables? I've tried using exit(), quit(), and sys.exit() but all variables are gone from the CLI so it's hard to see what the problem is.

Coder100 (18903)

Try adding some sort of breakpoint, like input() for easy inspection

input("breakpoint.   ")
OldWizard209 (1617)

Have you tried raising errors and sys.exit() after importing the sys module? If not, can you show us your code?

R2D2VaderBeef (8)

I'm not sure if there is, but what I would do is print() the related variables every time they are changed so you can see where it's going wrong.