Is there any way to set a breakpoint in a colab program and then inspect variable values?

Viewed 1184

Is there any way to set a breakpoint in a colab program and then inspect variable values? If not, what's the best way to debug a program while using colab--other than print statements?

1 Answers

There is a really good way to do this in Google Colab. After you have hit an error, you can create a new code block and run

%debug

An interactive shell is opened for you at the point of the error with the state still intact and you can examine what the values are.

Here is some documentation, it's from the Python Data Science Handbook by Jake VanderPlas.

You can also run

%pdb on

for this to happen automatically on every error

Related