textwrap.dedent()
textwrap.dedent() is a Python function in the Textwrap Module category. Removes common leading whitespace from all lines (for multiline strings). The syntax is textwrap.dedent(text). Parameters: text. Returns: Dedented string. A typical example: code = textwrap.dedent("""
def hello():
print("Hi")
"""). A close sibling is textwrap.wrap(), which wraps text into a list of lines, each at most `width` characters. A close sibling is textwrap.fill(), which similar to wrap() but joins the lines with newlines and returns a single string. A close sibling is textwrap.indent(), which adds a prefix to the beginning of selected lines. A close sibling is textwrap.shorten(), which truncates text to fit within `width` characters, adding a placeholder. More about this category: Text wrapping — wrap, fill, dedent, indent, shorten. Related Textwrap Module entries: textwrap.wrap(), textwrap.fill(), textwrap.indent(), textwrap.shorten(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.