[issue1859] textwrap doesn't linebreak on "\n"

Chris Jerdonek report at bugs.python.org
Sat Jul 28 07:56:39 CEST 2012


Chris Jerdonek <chris.jerdonek at gmail.com> added the comment:

> def wrap_paragraphs(text, width=70, **kwargs):
>     return [line for para in text.splitlines() for line in textwrap.wrap(para, width, **kwargs)]

I just want to point out that, at least for the purposes of this issue, I don't believe the above is equivalent to what we want.  For example--

>>> wrap_paragraphs('a\n\nb', replace_whitespace=False)
['a', 'b']

With replace_whitespace=False, we want to preserve newline information, which would instead mean a return value of--

['a', '', 'b']

----------

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


More information about the Python-bugs-list mailing list