Dev:Py/Scripts/Cookbook/Python/Reload

提供: wiki
< Dev:Py‎ | Scripts‎ | Cookbook‎ | Python
2017年4月4日 (火) 03:35時点におけるwiki>Lijenstinaによる版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

To support reload properly, try to access a package var: if it's there, reload everything

For older versions of Python 3 up to 3.4:

if "bpy" in locals():
    from imp import reload
    if "import_3ds" in locals():
        reload(import_3ds)
    if "export_3ds" in locals():
        reload(export_3ds)

Since Python 3.4, the imp module is deprecated and awaiting removal. Use importlib instead:

if "bpy" in locals():
    from importlib import reload
    if "import_3ds" in locals():
        reload(import_3ds)
    if "export_3ds" in locals():
        reload(export_3ds)

. .

Blender3D FreeTip.png
Important note
Add the reload code before any other imports (for instance, import bpy). Otherwise, it can fail to register the add-on