Проверка питона, если переменная - модуль

from types import ModuleType

isinstance(obj, ModuleType)
Thoughtful Toad