textwrap from Python 3.6 backport (plus a few tweaks)
Project description
textwrap3 is a compatibility back-port of Python 3.6’s textwrap module that supports Python 2.6 forward. 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file textwrap3-0.9.1.zip
.
File metadata
- Download URL: textwrap3-0.9.1.zip
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f044d25f0ca4d7554718d9abdc06f68946bfb64008dfc40d9590945e50c1120 |
|
MD5 | 34c7b20b65178a7fde6ec3ea658ef1c8 |
|
BLAKE2b-256 | 869ac8a6afe40c12aa76977f7966cb11a56e644a2621490fd48cab95fdb67304 |
File details
Details for the file textwrap3-0.9.1-py2.py3-none-any.whl
.
File metadata
- Download URL: textwrap3-0.9.1-py2.py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9965eb42ed413907487d5425e3218076d2ce602fdfe6d62388772554c2070cfd |
|
MD5 | d7c407a3872f9b29821442361a392fcf |
|
BLAKE2b-256 | e8783bb4b819ae7ab81ba0759788b28671d7ae13186544c333f973e6c91a6726 |