[Python-bugs-list] [ python-Bugs-577106 ] textwrap module can't cope with newlines

noreply@sourceforge.net noreply@sourceforge.net
Wed, 03 Jul 2002 13:51:51 -0700


Bugs item #577106, was opened at 2002-07-03 14:08
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577106&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Jon Ribbens (jribbens)
Assigned to: Greg Ward (gward)
Summary: textwrap module can't cope with newlines

Initial Comment:
The textwrap module cannot cope with newlines. By 
default, it replaces them with spaces, which is very 
annoying. However, this is livable with since you can 
manually set replace_whitespace to what its default 
should be, i.e. False.

However, the textwrap module appears not to know that 
a newline should reset the current column to zero, so 
even with replace_whitespace set to False, it does not 
wrap paragraphs properly.

Oh yes, and expand_tabs should be False by default as 
well ;-)

----------------------------------------------------------------------

>Comment By: Greg Ward (gward)
Date: 2002-07-03 16:51

Message:
Logged In: YES 
user_id=14422

The intention of TextWrapper.wrap() is to wrap a *single* 
paragraph -- so it really shouldn't pay any attention to 
newlines (IMHO).  If you want to wrap multiple paragraphs, you 
should split your text into paragraphs and pass them 
individually to wrap().

Please review the docs at 
http://www.python.org/dev/doc/devel/lib/module-textwrap.html 
and let me know if this is clear *from the docs*.  Since the 
docs are brand-new, you're excused if you haven't read them -- 
but this still might be a doc bug.

----------------------------------------------------------------------

Comment By: Jon Ribbens (jribbens)
Date: 2002-07-03 14:29

Message:
Logged In: YES 
user_id=76089

I have attached a patch which fixes the newlines problem. I'm 
afraid I think this module is rather a mess though.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577106&group_id=5470