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

noreply@sourceforge.net noreply@sourceforge.net
Thu, 04 Jul 2002 07:56:57 -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: Not a Bug
>Status: Closed
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-04 10:56

Message:
Logged In: YES 
user_id=14422

The module does exactly what it was intended and documented 
to do.  I have clarified the docstrings a bit to avoid future 
confusion.

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

Comment By: Jon Ribbens (jribbens)
Date: 2002-07-04 05:46

Message:
Logged In: YES 
user_id=76089

OK, the docs do say this (although the docstrings within the 
module, which is what I was using for documentation, don't).

However this simply means that the bug is in the module 
design rather than its implementation, and it should still be 
fixed.

What is this, some kind of competition to make the world's 
most complicated yet least useful text-wrap function? Sorry 
to be blunt but, I mean, *huh*?

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

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