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

textwrap.shorten

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


Import

import textwrap
from textwrap import shorten

Signature & Overview

textwrap.shorten(text, width, **kwargs)

Collapse and truncate the given text to fit in the given width.

Usage

import textwrap

assert textwrap.shorten('Hello   world from Python', width=16, placeholder='...') == 'Hello world...'

Gotchas

REPL Inspect

from textwrap import shorten
help(shorten)

Linked from

Related notes