Small Standard Library Projects
Textwrap Status Report
textwrap can format a small status message to a predictable width before a program prints it.
Textwrap Status Report
textwrap_status_report.py
import textwrap
width =
tasks = ["collect data", "validate rows", "publish report"]
message = "Pipeline finished: " + ", ".join(tasks)
wrapped = textwrap.wrap(message, width=width)
print("width=" + str(width))
for line in wrapped:
print("line=" + line)
print("lines=" + str(len(wrapped)))
import textwrap
width =
tasks = ["collect data", "validate rows", "publish report"]
message = "Pipeline finished: " + ", ".join(tasks)
wrapped = textwrap.wrap(message, width=width)
print("width=" + str(width))
for line in wrapped:
print("line=" + line)
print("lines=" + str(len(wrapped)))
import textwrap
width =
tasks = ["collect data", "validate rows", "publish report"]
message = "Pipeline finished: " + ", ".join(tasks)
wrapped = textwrap.wrap(message, width=width)
print("width=" + str(width))
for line in wrapped:
print("line=" + line)
print("lines=" + str(len(wrapped)))
wrapped output
Wrapping splits long text into lines that fit a chosen width.