imp.find_module(name [, path])
nameThe name of the module (directory or file without extension).
- If ommitted checks builtins first, then the sys.path directories
- must be a list of directory names
- Searches directories for the module
ReturnA 3-tuple of (file, pathname, description).
FileAn opened file or None if the module is a package (directory);
PathnameThe path to the file or directory.
DescriptionA 3-tuple of (suffix, mode, type):
- suffix is the file extension (e.g. .py)
- mode is one of r or rb (file was opened as readable text or binary)
- type is one of PY_SOURCE, PY_COMPILED, C_EXTENSION, or PKG_DIRECTORY
RaiseImportError if the module isn't found.
SubdirectoriesThe method doesn't accept dotted notation to indicate that the module is in a sub-package. Instead you have to find the package first then the module:
path = os.path.dirname(__file__)
f, p, d = find_module('directory', [path])
f_2, p_2, d_2 = find_module('module_name', [p]))