Message167709
Chris Jerdonek wrote:
> Here is an example on a paragraph with line breaks between paragraphs:
s/paragraph/text/
>>>> def wrap_paras(text, width=70, **kwargs):
> ... lines = [line for para in text.splitlines()
> ... for line in wrap(para, width, **kwargs)]
> ... return "\n".join(lines)
> ...
>>>> text = """\
> ... abcd abcd
> ...
> ... abcd abcd"""
>>>> print(wrap_paras(text))
> abcd abcd
> abcd abcd
>
> The edge case we're discussing determines whether line breaks between paragraphs are preserved in the result. (With current behavior, they are not.)
Having now more carefully read the docs (which, admittedly, I should
have done before responding the first time) I found this:
textwrap.wrap(text, width=70, **kwargs)
Wraps the single paragraph in text . . .
textwrap.fill(text, width=70, **kwargs)
Wraps the single paragraph in text, . . .
In other words, it is not designed to work on multiple paragraphs at
once. And the documentation is fine.
Move along, no bug to see here, move along... |
|
Date |
User |
Action |
Args |
2012-08-08 20:17:46 | ethan.furman | set | recipients:
+ ethan.furman, twouters, gward, jcea, pitrou, r.david.murray, chris.jerdonek |
2012-08-08 20:17:45 | ethan.furman | link | issue15510 messages |
2012-08-08 20:17:44 | ethan.furman | create | |
|