Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm: Storing variables in memory to be able to run code from a "checkpoint"

Tags:

python

pycharm

I've been searching everywhere for an answer to this but to no avail. I want to be able to run my code and have the variables stored in memory so that I can perhaps set a "checkpoint" which I can run from in the future. The reason is that I have a fairly expensive function that takes some time to compute (as well as user input) and it would be nice if I didn't have to wait for it to finish every time I run after I change something downstream.

I'm sure a feature like this exists in PyCharm but I have no idea what it's called and the documentation isn't very clear to me at my level of experience. It would save me a lot of time if someone could point me in the right direction.

like image 880
duncster94 Avatar asked Dec 09 '16 16:12

duncster94


2 Answers

Turns out this is (more or less) possible by using the PyCharm console. I guess I should have realized this earlier because it seems so simple now (though I've never used a console in my life so I guess I should learn).

Anyway, the console lets you run blocks of your code presuming the required variables, functions, libraries, etc... have been specified beforehand. You can actually highlight a block of your code in the PyCharm editor, right click and select "Run in console" to execute it.

like image 116
duncster94 Avatar answered Oct 18 '22 20:10

duncster94


This feature is not implement in Pycharm (see pycharm forum) but seems implemented in Spyder.

like image 2
PatriceG Avatar answered Oct 18 '22 21:10

PatriceG