Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

re-importing a module into a pycharm console doesn't update the code unless i delete/restart the console

The example shows:

I create a simple module (fibonacci calculator) I start a pycharm console, import the module, run the function inside console, and it works. Now I edit some print text in the module. Go back to the console and run "import fibagain"
The console seems to do this without complaining. But when I run the fib() function, it is still giving me results from the earlier version. I cannot make the console see the updated version of the fibagain.py file. If I delete the console and open it again, then 'import fibagain', running fib(3) will give me the latest version.

sorry, but not permitted to post proper image links here. This address shows the screencapture:

enter image description here

like image 952
user3556757 Avatar asked Apr 21 '14 13:04

user3556757


1 Answers

Instead of import again, you want:

reload(fibagain)

This will reload the updated module. (Note: This only works if fibagain had been imported some time earlier)

like image 175
sshashank124 Avatar answered Oct 04 '22 00:10

sshashank124