On this page
  1. textwrap.dedent
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

textwrap.dedent

Up: textwrap | Next: textwrap.fill
Rel: textwrap.fill, textwrap.indent, textwrap.shorten, textwrap.TextWrapper
Ref: docs.python.org — textwrap.dedent
Tags: #public #python3 #stdlib #textwrap


Import

import textwrap
from textwrap import dedent

Signature & Overview

textwrap.dedent(text)

Remove any common leading whitespace from every line in text.

Usage

import textwrap

block = '''
    line 1
      line 2
'''
assert textwrap.dedent(block).strip() == 'line 1\n  line 2'

Gotchas

REPL Inspect

from textwrap import dedent
help(dedent)

Linked from

Related notes