Live code edits when running script (or web server) in PyCharm

Can I configure PyCharm to pick up and re-compile code changes while I'm running a script in the IDE?

For example, let's say I have two files, main.py and foo.py. In main.py I simply have a while loop that calls a function in foo.

import foo
import time

while True:
foo.foo()
time.sleep(1)

And the function in foo.py is simple.

def foo():
print('hello')

When I run main.py in PyCharm, as expected "hello" is printed over and over again, once per second. While the script is running, I want to edit foo.py and change the printed message to "goodbye". Upon making this change I want PyCharm to automatically detect and process this change, so that the console starts showing "goodbye" instead of "hello".

Is this possible, without stopping and restarting the script?

Please sign in to leave a comment.