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

后端 未结 5 812
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 12:27

When I save a python source code file, I want to re-run the script. Is there a command that works like this (sort of like nodemon for node)?

5条回答
  •  长情又很酷
    2020-12-28 13:22

    The most similar way to nodemon I found is by using the watchdog package:

    pip install watchdog
    

    This comes with a utility called watchmedo:

    watchmedo shell-command \
     --patterns="*.py" \
     --command='python "${watch_src_path}"' \
     .
    

    Now just work on your .py and it will be executed every time you save the file.

提交回复
热议问题