ID EN
Inspect

getmodulename

Python 3.11

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.

Syntax

PYTHON
inspect.getmodulename(path)

See Also

importlib.machinery.all_suffixes() importlib