inspect.getmodulename()

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. Ch

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

inspect.getmodule()

inspect.getmodule(object) Try to guess which module an object was defined in.

inspect.getmembers()

inspect.getmembers(object[, predicate]) Return all the members of an object in a list of (name, value) pairs sorted by name. If the optional predicate argument is supplied, only members for which the predicate returns a true value are included. Note getmembers() will only return class attributes defined in the metaclass when the argument is a class and those attributes have been listed in the metaclass’ custom __dir__().

inspect.getinnerframes()

inspect.getinnerframes(traceback, context=1) Get a list of frame records for a traceback’s frame and all inner frames. These frames represent calls made as a consequence of frame. The first entry in the list represents traceback; the last entry represents where the exception was raised. Changed in version 3.5: A list of named tuples FrameInfo(frame, filename, lineno, function, code_context, index) is returned.

inspect.getgeneratorstate()

inspect.getgeneratorstate(generator) Get current state of a generator-iterator. Possible states are: GEN_CREATED: Waiting to start execution. GEN_RUNNING: Currently being executed by the interpreter. GEN_SUSPENDED: Currently suspended at a yield expression. GEN_CLOSED: Execution has completed. New in version 3.2.

inspect.getgeneratorlocals()

inspect.getgeneratorlocals(generator) Get the mapping of live local variables in generator to their current values. A dictionary is returned that maps from variable names to values. This is the equivalent of calling locals() in the body of the generator, and all the same caveats apply. If generator is a generator with no currently associated frame, then an empty dictionary is returned. TypeError is raised if generator is not a Python generator object. CPython implementation detail: This fun

inspect.getfullargspec()

inspect.getfullargspec(func) Get the names and default values of a Python function’s arguments. A named tuple is returned: FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations) args is a list of the argument names. varargs and varkw are the names of the * and ** arguments or None. defaults is an n-tuple of the default values of the last n arguments, or None if there are no default arguments. kwonlyargs is a list of keyword-only argument names. kwonlydefaults is

inspect.getframeinfo()

inspect.getframeinfo(frame, context=1) Get information about a frame or traceback object. A named tuple Traceback(filename, lineno, function, code_context, index) is returned.

inspect.getfile()

inspect.getfile(object) Return the name of the (text or binary) file in which an object was defined. This will fail with a TypeError if the object is a built-in module, class, or function.