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

textwrap.wrap

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


Import

import textwrap
from textwrap import wrap

Signature & Overview

textwrap.wrap(text, width=70, **kwargs)

Wrap a single paragraph of text, returning a list of wrapped lines.

Usage

import textwrap

assert textwrap.wrap('alpha beta gamma', width=10) == ['alpha beta', 'gamma']

Gotchas

REPL Inspect

from textwrap import wrap
help(wrap)

Linked from

Related notes