inspect.stack()

inspect.stack(context=1)[source]

Return a list of records for the stack above the caller’s frame.