hot-reload for python packages
Project description
HOW TO USE?
STEP 1
Import hot_import
into your python file with import hot_import
or from hot_import import EasyImport
STEP 2
Import the desired module as following import module_name
/!\ It will not work if you do from module_name import *
or from module_name import function
/!\
STEP 3
Create an object EasyImport that you will use to manage your modules
# main.py
from hot_import import EasyImport
import module
mods = EasyImport([module], auto_update=True)
module = mods.get_module(module)
STEP 4
Check if it's working, to proceed, you have to edit module.py
while your code is running
# module.py
def hello():
return "Hello world!"
# main.py
from hot_import import EasyImport
import time
import module
mods = EasyImport([module], auto_update=True)
module = mods.get_module(module)
while True:
print(module.hello())
time.sleep(1)
STEP 5 (optional)
You can add an event on_update to help you debugging
# main.py
from hot_import import EasyImport
import time
import module
mods = EasyImport([module], auto_update=True)
module = mods.get_module(module)
@mods.on_update()
def on_update(module):
print(f"The module {module.module_name} has been updated!")
while True:
print(module.hello())
time.sleep(1)
DISCLAIMER
This library is new and may contain some errors
Otherwise, have fun with it as long as you declare my work
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hot-import-1.0.1.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for hot_import-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac5741401e7e1d9c358a70c5ff67bfd13350b67a09b0539af6fa8a3a3f218940 |
|
MD5 | e37cd7ee821ff338bf6ac593cf8fc171 |
|
BLAKE2b-256 | d33725376972af6d4499a20af68a9570ee436cd8317598dbf03443e9d4de6ac9 |