[New-bugs-announce] [issue18725] Multiline shortening

Serhiy Storchaka report at bugs.python.org
Tue Aug 13 12:12:58 CEST 2013


New submission from Serhiy Storchaka:

Functions in the textwrap module works with multiline text except a newly added (in issue18585) the shorten() function. Wrapping and shortening a multiline text using existing textwrap function is not a trivial job.

I propose to add two new parameters to the TextWrap class and wrap() and fill() functions: max_lines and placeholder. If the max_lines argument is specified then wrapped text truncated to max_lines and the last line shortened to the width argument.

>>>print(textwrap('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', width=40, max_lines=3))
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore (...)

The shorten() function then will be just a particular case of fill() with max_lines=1.

----------
components: Library (Lib)
messages: 195065
nosy: barry, ezio.melotti, georg.brandl, pitrou, python-dev, r.david.murray, serhiy.storchaka, stevenjd, vajrasky
priority: normal
severity: normal
status: open
title: Multiline shortening
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18725>
_______________________________________


More information about the New-bugs-announce mailing list