Skip to main content

try_importing

Try importing a test label, and return (is_importable, is_package).

Relative labels like "." and ".." are seen as directories.

def try_importing(
label: string
) - > tuple

Try importing a test label, and return (is_importable, is_package). Relative labels like "." and ".." are seen as directories.

Parameters

NameTypeDescription
labelstringThe module or package name to attempt to import, including relative path indicators like "." or ".."

Returns

TypeDescription
tupleA tuple containing two booleans: the first indicates if the module was successfully imported, and the second indicates if the imported module is a package.