# **HOW TO USE?**
## STEP 1
Import `hot_import` into your python file with `import hot_import` or `from hot_import import HotImport`
## STEP 2
Import the desired module as following `import module_name` or `from module_name import function`
## STEP 3
Create an object HotImport that you will use to manage your modules
```py
# main.py
from hot_import import HotImport
import module
from module2 import function
mods = HotImport([module, function], 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
```py
# module.py
def hello():
return "Hello world!"
```
```py
# module2.py
def function():
return "This is a function!"
```
```py
# main.py
from hot_import import HotImport
import time
import module
from module2 import function
mods = EasyImport([module, function], auto_update=True)
module = mods.get_module(module)
while True:
print(module.hello())
print(function2())
time.sleep(1)
```
### STEP 5 (optional)
You can add an event on_update to help you debugging
```py
# 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.__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
Raw data
{
"_id": null,
"home_page": "https://github.com/ThePhoenix78/hot-import",
"name": "hot-import",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "hot-reload,live reload,live update,hot reload",
"author": "ThePhoenix78",
"author_email": "thephoenix788@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/22/56/81715f8671724c8ad2130c0d9aa9f18f2de5a8f99dcb8ad06dbf4958bb96/hot-import-2.0.0.tar.gz",
"platform": null,
"description": "# **HOW TO USE?**\r\n\r\n## STEP 1\r\n\r\nImport `hot_import` into your python file with `import hot_import` or `from hot_import import HotImport`\r\n\r\n## STEP 2\r\n\r\nImport the desired module as following `import module_name` or `from module_name import function`\r\n\r\n## STEP 3\r\n\r\n\r\nCreate an object HotImport that you will use to manage your modules\r\n\r\n\r\n```py\r\n# main.py\r\nfrom hot_import import HotImport\r\n\r\nimport module\r\nfrom module2 import function\r\n\r\n\r\nmods = HotImport([module, function], auto_update=True)\r\nmodule = mods.get_module(module)\r\n```\r\n\r\n\r\n### STEP 4\r\n\r\nCheck if it's working, to proceed, you have to edit `module.py` while your code is running\r\n\r\n```py\r\n# module.py\r\ndef hello():\r\n return \"Hello world!\"\r\n```\r\n```py\r\n# module2.py\r\ndef function():\r\n return \"This is a function!\"\r\n```\r\n```py\r\n# main.py\r\nfrom hot_import import HotImport\r\nimport time\r\n\r\nimport module\r\nfrom module2 import function\r\n\r\n\r\nmods = EasyImport([module, function], auto_update=True)\r\nmodule = mods.get_module(module)\r\n\r\nwhile True:\r\n print(module.hello())\r\n print(function2())\r\n time.sleep(1)\r\n```\r\n\r\n\r\n### STEP 5 (optional)\r\n\r\n\r\nYou can add an event on_update to help you debugging\r\n\r\n```py\r\n# main.py\r\nfrom hot_import import EasyImport\r\nimport time\r\n\r\nimport module\r\n\r\n\r\nmods = EasyImport([module], auto_update=True)\r\n\r\nmodule = mods.get_module(module)\r\n\r\n\r\n@mods.on_update()\r\ndef on_update(module):\r\n print(f\"The module {module.__name__} has been updated!\")\r\n\r\n\r\nwhile True:\r\n print(module.hello())\r\n time.sleep(1)\r\n```\r\n\r\n\r\n## DISCLAIMER\r\n\r\nThis library is new and may contain some errors\r\n\r\nOtherwise, have fun with it as long as you declare my work\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "hot-reload for python packages",
"version": "2.0.0",
"project_urls": {
"Download": "https://github.com/ThePhoenix78/hot-import/tarball/master",
"Homepage": "https://github.com/ThePhoenix78/hot-import"
},
"split_keywords": [
"hot-reload",
"live reload",
"live update",
"hot reload"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eb358d5bae96301b259992306b5a1a5ab05727ed0e76f245abd0c17359adb68b",
"md5": "87523fb4e03fede0abe08a4b7cb9f45f",
"sha256": "2e2d0831c68742951644e96711e0cf599d30d929e04a3ef03bafaa360c0c1da4"
},
"downloads": -1,
"filename": "hot_import-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "87523fb4e03fede0abe08a4b7cb9f45f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4167,
"upload_time": "2023-12-04T11:52:15",
"upload_time_iso_8601": "2023-12-04T11:52:15.624601Z",
"url": "https://files.pythonhosted.org/packages/eb/35/8d5bae96301b259992306b5a1a5ab05727ed0e76f245abd0c17359adb68b/hot_import-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "225681715f8671724c8ad2130c0d9aa9f18f2de5a8f99dcb8ad06dbf4958bb96",
"md5": "aa24f6ccab727703d0ec3b4016a6e7ea",
"sha256": "12c27f6863254d435d35ec57e07fd7e01ba0436134660d4b3bdf03e5b2a3003d"
},
"downloads": -1,
"filename": "hot-import-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "aa24f6ccab727703d0ec3b4016a6e7ea",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4100,
"upload_time": "2023-12-04T11:52:17",
"upload_time_iso_8601": "2023-12-04T11:52:17.267297Z",
"url": "https://files.pythonhosted.org/packages/22/56/81715f8671724c8ad2130c0d9aa9f18f2de5a8f99dcb8ad06dbf4958bb96/hot-import-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-04 11:52:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ThePhoenix78",
"github_project": "hot-import",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "hot-import"
}