Python Sprawdź, czy zmienna jest modułem

from types import ModuleType

isinstance(obj, ModuleType)
Thoughtful Toad