inspect.getouterframes()

inspect.getouterframes(frame, context=1)[source]

Get a list of records for a frame and all higher (calling) frames.

Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.