Skip to main content
travisci PyPI Package latest release Supported versions Supported implementations Wheel packaging support Test line coverage

textwrap3 is a compatibility back-port of Python 3.6’s textwrap module that supports Python 2.6 forward. (Though honestly, if you’re not already using at least 2.7, you’re way behind the times!)

This makes a few new APIs such as shorten and the max_lines parameter available in a compatible way to all Python versions typically in current use.

Import and use it like you would textwrap from the standard library:

from textwrap3 import wrap

text = 'long text here...'
print(wrap(text, 40))

The standard textwrap documentation is the best reference material.

Bias and Tweaks

By design, Python 3 sensibilities and expectations rule. Especially when processing text that includes Unicode characters, textwrap3’s results may differ a bit from those of the textwrap of the underlying Python version (esp. 2.x). In particular, textwrap3 uses the re.UNICODE flag so that non-ASCII characters such as accented letters are considered legitimate word characters.

It also adds one tweak, considering the Unicode em-dash ('\N{EM DASH}' or u'\u2014') identical to the simulated ASCII em-dash '--'.

Notes

  • See CHANGES.yml for the Change Log.

  • This module is almost entirely the work of Gregory P. Ward (textwrap’s original author) plus enhancements from the Python community. This separate packaging is just a delivery and compatibility vehicle. It contributes cross-Python version compatibility shims, a few additional tests, and better handling of real em-dashes. The vast majority of functionality still comes from the standard textwrap code base, as of the Python 3.6 release.

Installation

To install or upgrade to the latest version:

pip install -U textwrap3

You may need to prefix these with sudo to authorize installation. In environments without super-user privileges, you may want to use pip’s --user option, to install only for a single user, rather than system-wide. Depending on your system configuration, you may also need to use separate pip2 and pip3 programs to install for Python 2 and 3 respectively.

Release files for textwrap3 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textwrap3 0.9.2
File Size Uploaded
textwrap3-0.9.2.zip 25.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textwrap3 0.9.2
File Interpreter ABI Platform
textwrap3-0.9.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 37.2 kB

Release files / textwrap3-0.9.2.zip

Download URL textwrap3-0.9.2.zip
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5008eeebdb236f6303dcd68f18b856d355f6197511d952ba74bc75e40e0c3414
BLAKE2b-256 checksum
How to use checksums
4d02cef645d4558411b51700e3f56cefd88f05f05ec1b8fa39a3142963f5fcd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release files / textwrap3-0.9.2-py2.py3-none-any.whl

Download URL textwrap3-0.9.2-py2.py3-none-any.whl
Size 12.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bf5f4c40faf2a9ff00a9e0791fed5da7415481054cef45bb4a3cfb1f69044ae0
BLAKE2b-256 checksum
How to use checksums
779ca53e561d496ee5866bbeea4d3a850b3b545ed854f8a21007c1e0d872e94d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release history Release notifications | RSS feed

This release

0.9.2 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page