def say(msg):
"""Print a message.
Unlike print(), this deals with de-denting and wrapping of text to fit
within the width of the terminal.
Paragraphs separated by blank lines in the input will be wrapped
separately.
"""
msg = str(msg)
msg = re.sub(r'^[ \t]*(.*?)[ \t]*$', r'\1', msg, flags=re.M)
width = get_terminal_size()[0]
paragraphs = re.split(r'\n(?:[ \t]*\n)', msg)
formatted = (textwrap.fill(p.strip(), width=width) for p in paragraphs)
print('\n\n'.join(formatted))
评论列表
文章目录