Is it possible to develop code in debug mode?


Is it possible to develop python code in debug mode?

What I mean is that I would like to possibility to run a program to a breakpoint and then develop code in the console. In this way I would like to try/test code in the console and then copy correct parts from the console to the editor.

Developing R code in this way using Eclipse/Statet is a very fast/agile experience compared to the cycle of writing code, debugging, analyzing the error, changing code and moving on to the next bug (possibly on the next line).

As far as I know PyCharm only supports the evaluation of one single statement. More specific it is not possible to change the state of the program being debugged using console statements (for example declare new variables)

Comment actions Permalink
No, there is no "hotswap" as there is in R or Java. However, you still can do quite a log of things from the evaluate expression popup. You should be able to change values of variables, inspect the value of arbitrary statements (don't get scared by the red curly underlines – your expression might still evaluate). You can probably also create variables by adding to the appropriate dicts.

However, in the long run I would recommend working with tests. You could write tests for one piece of code at a time. They would be quite small and exercise one small aspect of your application. Basically, like writing your console sessions down. As a consequence, they are very short and therefore quite easy to debug. You can find more info about this under the keyword TDD (test driven development).
Comment actions Permalink
Hi boojum,

PyCharm actually has command line in debug session (it's quite undiscoverable though).
Run Debug session, open Console tab in Debug toolwindow and click "Show command line" icon.
Screenshot from 2014-02-17 14:30:32.png
Comment actions Permalink
it's quite undiscoverable though

+1 on that! :) I had to search the forum to find out its existence.

Please sign in to leave a comment.