def isPackage(module):
    """Given an object return True if the object looks like a package"""
    if not isinstance(module, types.ModuleType):
        return False
    basename = os.path.splitext(os.path.basename(module.__file__))[0]
    return basename == '__init__'
Given an object return True if the object looks like a package
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/runner.py