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 Distribution
minireload-0.0.8.tar.gz
(7.7 kB
view hashes)
Built Distribution
Close
Hashes for minireload-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bec0e4d0d49b96c3c890d5a0880b4dd034a3763aa8e24af583238af0234fca21 |
|
MD5 | c2d0ae36e69f6b3e76087732b3974a06 |
|
BLAKE2b-256 | 16fbee1354d8646ae6ebfdc600217490fa648e91abc1617e5c94f44abedd4e70 |