[New-bugs-announce] [issue26214] textwrap should minimize breaks

Tuomas Salo report at bugs.python.org
Wed Jan 27 03:08:41 EST 2016


New submission from Tuomas Salo:

This code:

    import textwrap
    textwrap.wrap("123 123 1234567", width=5)

currently* produces this output:

    ['123', '123 1', '23456', '7']

I would expect the textwrap module to only break words when absolutely necessary. That is, I would have expected it to produce one break less:

    ['123', '123', '12345', '67']

This is of course a matter of taste - the current implementation produces more efficiently filled lines.

(* I only have access to Python 2.7 and 3.4)

----------
messages: 258999
nosy: Tuomas Salo
priority: normal
severity: normal
status: open
title: textwrap should minimize breaks
type: behavior
versions: Python 2.7, Python 3.4

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


More information about the New-bugs-announce mailing list