inspect.getmodulename(path)
Return the name of the module named by the file path, without including the names of enclosing packages. The file extension is checked against all of the entries in importlib.machinery.all_suffixes()
. If it matches, the final path component is returned with the extension removed. Otherwise, None
is returned.
Note that this function only returns a meaningful name for actual Python modules - paths that potentially refer to Python packages will still return None
.
Changed in version 3.3: This function is now based directly on importlib
rather than the deprecated getmoduleinfo()
.
Please login to continue.