Check if a parameter is a Python module?
>>> import inspect, os
>>> inspect.ismodule(os)
True
This seems a bit hacky, but:
>>> import sys
>>> import os
>>> type(os) is type(sys)
True
from types import ModuleType
isinstance(obj, ModuleType)