Access python console and program variables after program finished running?

Completed
I am considering PyCharm as my main Python IDE, but I can't seem to find a way to do what is my favorite feature of Spyder. After running a program everything is just available in the python console. I can type in any variable or object and tweak it or run other code on it. However in PyCharm, it seems like once you get the "Process finished with exit code 0", the console is shutdown with no more access to any of the code run. Is there some way to keep the console alive with all that information? I'm not a fan of needing to create an extra breakpoint at the end of the program and debug every time I want to have access to anything in the code.

Also when going to tools/run python console, this console is disconnected from what is being run. I would really just like a persistent console that whatever program I run runs in. Is there a way to make it when I run the program it shows up in that console instead of making its own separate one?
3 comments
Comment actions Permalink
Hi, unfortunately there is no way yet to stop after script execution with the access to variables. Please vote for the feature: http://youtrack.jetbrains.com/issue/PY-11430
As for console during debugging, you can press 'Show command line' button in debugger console output tab: http://www.jetbrains.com/pycharm/webhelp/debug-tool-window-console.html
0
Comment actions Permalink

I ended up here searching for this feature. It has been implemented and it's under Run > Edit configurations > Run with Python console

Great job devs :)

7
Comment actions Permalink

This doesn't work if you amend the code. 

 

Is there a way to run the first part of the code in PyCharm and store it in memory and then keep working on and testing/rerunning another part of the code without a need of returning the first part each time?

This will be similar to running code in Jupiter Notebook where you can split code into multiple cells. In this example you will run a first cell (which already has been tested and which is loading data and performing complex calculations which requires time) and keep working on and re-running code in second cell to see results. Here second cell is using variables computed in the first cell, but it doesn't need to rerun the first cell - variables from the first cell are keept in memory for the whole time.

0

Please sign in to leave a comment.