hot reloading / swapping with Python

deamon picture deamon · Oct 5, 2010 · Viewed 19k times · Source

I want code changes to take effect immediately during development. How can I detect changed files and reload them in the running Python (2.7) application?

Edit:

After reading the pages linked by 'Ivo van der Wijk', I think it would be best to restart the web application when code changes - like Django does. So the actual question is: How to monitor file modifications?

Answer

Jesper Borgstrup picture Jesper Borgstrup · Nov 10, 2011

I wanted the same effect for some of my Python scripts, so I went on and made the script SourceChangeMonitor.py. You can find it with instructions here. If you just want the script, here is a direct link