I was looking for a way to replicate in Python the behavior of ghcid in Haskell, that is: re-evaluate the content of a file at each change.
IPython can do it but only with precise functions, I wanted all the file for rapid prototyping.
My solution is to use Entr, which is “A utility for running arbitrary commands when files change”.
A simple example with a python program named “main.py”:
ls main.py | entr python main.py
Now each time you save main.py python will run again.