How do i watch python source code files and restart when i save?

While there are probably ways to do this within the python ecosystem such as watchdog/watchmedo ( ), and maybe even linux scripting options with inotifywait ( ), for me, the easiest solution by far was... to just use nodemon! What I didn't know is that although the github tagline of nodemon is "Monitor for any changes in your node.js application and automatically restart the server - perfect for development" actually nodemon is a delicously generic tool and knows that .py files should be executed with python for example. Here's where I think the magic happens:

End result is that the command line below totally works. Yay!

$ nodemon
[nodemon] starting `python`

You can install nodemon to watch for file changes.


npm i -g nodemon

Then to use:

nodemon --exec python3 

This is for when you use python3 in the command line. On windows you can also use 'py' instead.