Message167712
Also you will note that the return of the empty list for an empty line is exactly what you want for wrapping multiple line-break-delimited paragraphs. Consider:
>>> doc = "a para\nanother para\n\na third, but with an extra blank line between\n"
>>> for line in doc.splitlines():
... print('\n'.join(textwrap.wrap(line, width=5)))
... if line:
... print()
a
para
anoth
er
para
a thi
rd,
but
with
an
extra
blank
line
betwe
en
In other words, we need to add a blank line after our formatted paragraph, unless it is empty, in which case we don't want to add one or we'll have an extra. This assumes that single-line-paragraphs do not have blank lines between them...if they do, then the algorithm is even simpler, as you don't need the if. |
|
Date |
User |
Action |
Args |
2012-08-08 20:34:55 | r.david.murray | set | recipients:
+ r.david.murray, twouters, gward, jcea, pitrou, chris.jerdonek, ethan.furman |
2012-08-08 20:34:55 | r.david.murray | set | messageid: <1344458095.13.0.911347910181.issue15510@psf.upfronthosting.co.za> |
2012-08-08 20:34:54 | r.david.murray | link | issue15510 messages |
2012-08-08 20:34:54 | r.david.murray | create | |
|