{
  "id": "python-textwrap-table",
  "kind": "table",
  "slug": "python-textwrap",
  "iil_id": null,
  "note_url": "https://iinventedlight.com/library/notes/python-textwrap/",
  "title": "Python textwrap - wrap, fill, shorten, dedent and indent plain text",
  "columns": [
    "name",
    "source",
    "detail"
  ],
  "rows": [
    {
      "name": "wrap(text, width=70)",
      "source": "Python docs",
      "detail": "a list of output lines, without final newlines"
    },
    {
      "name": "fill(text, width=70)",
      "source": "Python docs",
      "detail": "a single string; shorthand for \"\\n\".join(wrap(text))"
    },
    {
      "name": "shorten(text, width)",
      "source": "Python docs",
      "detail": "collapsed whitespace, then words dropped from the end plus the placeholder ' [...]'"
    },
    {
      "name": "dedent(text)",
      "source": "Python docs",
      "detail": "text with common leading whitespace removed from every line"
    },
    {
      "name": "indent(text, prefix)",
      "source": "Python docs",
      "detail": "text with prefix added to lines that are not only whitespace"
    },
    {
      "name": "width",
      "source": "Python docs",
      "detail": "is the maximum line length. As long as no single word is longer than width, no output line will be longer."
    },
    {
      "name": "break_long_words=True",
      "source": "Python docs",
      "detail": "splits words longer than width; break_on_hyphens=True lets lines break after hyphens."
    },
    {
      "name": "dedent()",
      "source": "Python docs",
      "detail": "lets triple-quoted strings line up with the left edge while staying indented in source. Tabs and spaces are both treated as whitespace, but they are not equal."
    },
    {
      "name": "indent()",
      "source": "Python docs",
      "detail": "takes an optional predicate to choose which lines get the prefix."
    }
  ],
  "related_slugs": [
    "python-f-strings",
    "python-argparse",
    "python-json"
  ],
  "license": "CC-BY-4.0",
  "source_license": "PSF-2.0 (Python docs); PSF-2.0 (python/cpython (GitHub)); prose restates cited source lines in own words",
  "as_of": "2026-11-18",
  "status": "fill-draft-20261118",
  "note": "Restated from the note's GREEN sources; check those sources before relying on a value."
}