def format(self):
"""Format the stack ready for printing.
Returns a list of strings ready for printing. Each string in the
resulting list corresponds to a single frame from the stack.
Each string ends in a newline; the strings may contain internal
newlines as well, for those items with source text lines.
"""
result = []
for frame in self:
row = []
row.append(u(' File "{0}", line {1}, in {2}\n').format(
_some_fs_str(frame.filename), frame.lineno, frame.name))
if frame.line:
row.append(u(' {0}\n').format(frame.line.strip()))
if frame.locals:
for name, value in sorted(frame.locals.items()):
row.append(u(' {name} = {value}\n').format(name=name, value=value))
result.append(u('').join(row))
return result
评论列表
文章目录