Small library for live code reloading
Project description
minireload
Small library for live code reloading of python scripts. Basically just a nicer front-end for superreload + exception handling. Requires only the watchdog library to check for filesystem changes.
Setup
Available via pip:
pip3 install minireload
Usage
As demonstrated by the code in example/.
main.py
from impl import main
if __name__ == "__main__":
# Since the __main__ file cannot be reloaded by the python interpreter,
# it just refers to another module, which contains the actual code.
main()
impl.py
import time
import minireload as mr
def update():
print("Try changing me!")
time.sleep(0.1)
return 42
def main():
enable_autoreload = True
if enable_autoreload:
func = mr.WrappingReloader(update)
else:
func = update
while True:
res = func()
if type(res) == mr.ReloadErrorInfo:
print("Everything is awful:", res)
else:
print("Everything is awesome:", res)
The update function is wrapped in a WrappingReloader. By default this
reloads the toplevel module the function belongs to and handles exceptions,
which may happen during live code editing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minireload-0.0.9-py3-none-any.whl.
File metadata
- Download URL: minireload-0.0.9-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bdb1852a84eb86a0c92c69d4d2f0e926b1367b9d2ec3ab18cec424da44b44d8
|
|
| MD5 |
7cf900a41c445bd5254776bf84f25d88
|
|
| BLAKE2b-256 |
e97d25d2a564ee9fe6d5e64741bb39315a7caba456b07534649ba1c41e9cf281
|