textwrap3
textwrap from Python 3.6 backport (plus a few tweaks)
What it is and what it does
textwrap3 is a backport of Python 3.6's textwrap module designed to run on older Python versions, from 2.6 forward. It exposes newer APIs like shorten() and the max_lines parameter to codebases stuck on Python 2 or early Python 3 releases. The module is a near-direct copy of the standard library implementation, with one notable tweak: it treats Unicode em-dashes (U+2014) the same as ASCII em-dashes (--) when wrapping text, and it applies the re.UNICODE flag so that accented and non-ASCII characters are recognized as legitimate word characters.
Because the package is a compatibility shim for end-of-life Python versions, it is only relevant if you maintain legacy code that cannot upgrade to modern Python. The package itself is abandoned—no releases since January 2019—and the Python versions it targets are no longer supported by the Python community.
Use it for:
- Wrap and fill text in Python 2.7 codebases using the same API as Python 3.6's textwrap.
- Handle Unicode text with accented characters and em-dashes correctly across Python 2 and early Python 3.
- Use the shorten() function in projects locked to Python 2.6–3.5 where the standard library lacks it.
- Maintain consistent text-wrapping behavior across a codebase that must support both Python 2 and Python 3.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Backports Python 3.6's textwrap module to earlier Python versions, making APIs like shorten() and max_lines available across Python 2.6 and 3.x with improved Unicode handling.
No. The package is abandoned (last release January 2019) and targets Python versions (2.6–3.7) that are end-of-life and no longer receive security updates. Modern Python projects should use the standard library textwrap directly. Only consider this if you are maintaining legacy code on unsupported Python versions and cannot upgrade—in that case, the low install friction and permissive license make it technically viable, but the lack of maintenance is a significant risk.
Install
textwrap3 on PyPI
pip
pip install textwrap3uv
uv add textwrap3poetry
poetry add textwrap3Installing textwrap3
Before you install
Low install friction with no runtime dependencies. However, the package is abandoned—last commit was 2019-01-23 and no releases in 2760 days. It targets Python versions (2.6, 2.7, 3.3–3.7) that are now end-of-life, making it unsuitable for modern projects.
License in practice
Licensed under the Python Software Foundation License (permissive), which poses no restrictions on use or redistribution in most contexts.
Quickstart
pip install textwrap3
from textwrap3 import wrap
text = 'long text here...'
print(wrap(text, 40))
Verify before relying
- Whether textwrap3's Unicode and em-dash handling differs meaningfully from modern Python's textwrap in current use.
- Whether any of the target Python versions (2.6–3.7) remain in active use in the reader's environment.
Package facts
| License | Python Software Foundation License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,760 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,313,048/month — #4,071 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: textwrap3-0.9.2-py2.py3-none-any.whl
Keywords: text, wrap, fill, textwrap
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
ansiwrapWraps and formats text while correctly handling…
permissive · top 5,000 on PyPI
backports.csvProvides Python 3's csv module API for Python…
unclear · top 15,000 on PyPI
traceback2Provides a backport of Python's traceback…
permissive · top 5,000 on PyPI
configparser2Backport of Python 3's configparser module to…
permissive · top 15,000 on PyPI
unicodedata2Provides updated Unicode character data tables…
permissive · top 15,000 on PyPI
contextlib2contextlib2 backports the Python standard…
permissive · top 5,000 on PyPI
HTMLParserProvides HTMLParser from Python 2.7 as a…
permissive · top 15,000 on PyPI
backports.shutil_get_terminal_sizeProvides the get_terminal_size() function for…
permissive · top 15,000 on PyPI
zipfile36Provides a backport of Python 3.6's zipfile…
permissive · top 5,000 on PyPI
pickle5Backports the pickle 5 protocol (PEP 574) and…
permissive · top 15,000 on PyPI