Python verifique se a variável é módulo
from types import ModuleType
isinstance(obj, ModuleType)
Thoughtful Toad
from types import ModuleType
isinstance(obj, ModuleType)