Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/say4n/hotreload
hot reload your python code!
https://github.com/say4n/hotreload
Last synced: about 1 month ago
JSON representation
hot reload your python code!
- Host: GitHub
- URL: https://github.com/say4n/hotreload
- Owner: say4n
- License: mit
- Created: 2020-06-11T14:12:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T21:14:12.000Z (over 1 year ago)
- Last Synced: 2024-08-08T05:17:47.469Z (about 2 months ago)
- Language: Python
- Size: 21.5 KB
- Stars: 320
- Watchers: 9
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hotreload.py
hot reload your python code!
Run any arbitrary python script every time the code changes in the file.
## installation
Get the package from PyPI with `pip3 install hotreload`.
## warning
You shouldn't do this and this can have [unexpected, unintended](https://news.ycombinator.com/item?id=23516018) repurcusions. Proceed with caution, you have been warned!
## usage
Say you have script (`script.py`) that you want to run every time the code
changes in that file.To do that, it is as simple as doing this:
```python
import time
import logging
from hotreload import Loaderif __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
script = Loader("script.py")while True:
# Check if script has been modified since last poll.
if script.has_changed():
# Execute a function from script if it has been modified.
script.main()time.sleep(1)
```### author
Sayan Goswami © 2020