Python inject/evaluate/run python code while process is already running, for example, infinite loop counter = 0 while True: counter += 1 print(f"baz: {counter}") time.sleep(1) I would like to attach/spawn python interpreter (preferably interactive python interpreter) and for example change value of counter I think this would be very cool & useful for game development where i can write new code and edit values while the game is running. i was able to do this: import time import code import threading counter = 0 def start_repl(): code.interact(local=globals()) threading.Thread(target=start_repl, daemon=True).start() while True: counter += 1 print(f"baz: {counter}") time.sleep(1) but its not that interactive and python prompt and input is in the same terminal as code baz: x output so it makes it cumbersome to use. by interactive i mean, tab symbol completion in terminal. Continue reading...