Blender Python - Force reload of module while importing all its classes

Viewed 500

I am developing in Python/Blender, and have two needs here:

  1. Import all the individual classes from my module (because they must each be registered with blender)
  2. Reload the module itself each time the script is executed (to prevent caching while I'm developing the plugin and press "reload scripts")

Currently I am doing this (in __init__.py):

from importlib import reload
from .MyPlugin import *

reload(MyPlugin)

classes = [ClassA, ClassB, ClassC]
# register each class, not shown here

However the reload(MyPlugin) line causes an error: "MyPlugin is not defined".

Originally I tried reloading each of the classes instead, but it raised an error that reload expects a module.

1 Answers
Related