inspect.getmoduleinfo()

inspect.getmoduleinfo(path)

Returns a named tuple ModuleInfo(name, suffix, mode, module_type) of values that describe how Python will interpret the file identified by path if it is a module, or None if it would not be identified as a module. In that tuple, name is the name of the module without the name of any enclosing package, suffix is the trailing part of the file name (which may not be a dot-delimited extension), mode is the open() mode that would be used ('r' or 'rb'), and module_type is an integer giving the type of the module. module_type will have a value which can be compared to the constants defined in the imp module; see the documentation for that module for more information on module types.

Deprecated since version 3.3: You may check the file path’s suffix against the supported suffixes listed in importlib.machinery to infer the same information.

doc_python
2016-10-07 17:35:01
Comments
Leave a Comment

Please login to continue.