How to do line wrapping? 
Author Message
 How to do line wrapping?

Hi,

Is there a python module that can help with reformatting a plain text
file so that all lines are less then a certain length?  It would have
to not cut words in half.  Just wanted to know, before I write it
myself.

Thanks!

 - Robb



Tue, 30 Jul 2002 03:00:00 GMT  
 How to do line wrapping?
Robb,

Your question was asked a few days ago and received the
following responses:

Brad Howes response:
http://x23.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=582180658&CONTEXT=950287138.1549008936

Hamish Lawson posted a link to his code:
http://www.cs.st-andrews.ac.uk/~hamish/python/TextFormatter.py

My response:
http://x23.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=582119928&CONTEXT=950287138.1549008936

Both Brad and Hamish wrote their own.  I used the standard
formatter.py module.  I'm wondering if formatter.py is
unpopular because it's a less well-known module or if
the documentation needs clarifying or if it's just
unwieldy for simple wordwrap tasks.

Jeff Bauer
Rubicon Research



Tue, 30 Jul 2002 03:00:00 GMT  
 How to do line wrapping?
Hi,

I just downloaded, modified and installed your script as a Zope external method.  This was
pretty easy although I'm new at it.  Thanks.

There seems to be one problem, though: Every paragraph has two blank lines at the end.
The problem is the call in main:

f.end_paragraph(1)

...This makes the 2 blank lines.  If I change this to a 2, then I get 3 blank lines.  If I
change it to a zero, though, then I get zero blank lines!  Is this a bug?

Thanks,
Robb



Tue, 30 Jul 2002 03:00:00 GMT  
 How to do line wrapping?
[Jeff Bauer, line-wrapping code]

Quote:
> ...
> Both Brad and Hamish wrote their own.  I used the standard
> formatter.py module.  I'm wondering if formatter.py is
> unpopular because it's a less well-known module or if
> the documentation needs clarifying or if it's just
> unwieldy for simple wordwrap tasks.

It's a continuing problem in Python:  new users especially get e{*filter*}d over
how easy it is to build frameworks for solving whole classes of problems
"once & for all".  Then they discover nobody uses their code:  it's often
easier in Python to write a special-case solution from scratch than to
figure out how to use a framework, some of which are so overly general that
it can be hard even to see that your current problem is an instance!

This isn't "a problem" so much as that it's delightful -- consider the
alternatives <wink>.

christian's-"stackless-python"-considered-a-framework-
    so-general-even-guido-can't-see-its-obvious-value<wink>-ly
    y'rs  - tim



Tue, 30 Jul 2002 03:00:00 GMT  
 How to do line wrapping?

Quote:

>It's a continuing problem in Python:  new users especially get e{*filter*}d over
>how easy it is to build frameworks for solving whole classes of problems
>"once & for all".  Then they discover nobody uses their code:  it's often
>easier in Python to write a special-case solution from scratch than to
>figure out how to use a framework, some of which are so overly general that
>it can be hard even to see that your current problem is an instance!

I wonder if part of that has to do with lack of documentation.
If we could add full text searches of module documentation to
VoP or the hypothetical CPyAN,  it might make things easier..

But I suspect part of it is that if you want something to be popular,
you can't just write it.. You've got to market it so people know it's there,
and document it so that it becomes approachable. Zope, for example, is
well marketed, but not (yet) well documented.. On the other hand,
most of the standard python modules are well documented, but not
necessarily well marketed (they're not on VoP, for example).

Just because it happens to be easy to write a special case doesn't mean
it *necessarily* has to be easier than figuring out someone elses solution.
As you say, it's only often the case. But I would think that if we found a
way
to document and organize even some of the well-designed modules,
frameworks and whatnot out there, then it would free up much more
programmer energy to work on totally new stuff...

-Michal
http://www.*-*-*.com/



Wed, 31 Jul 2002 03:00:00 GMT  
 How to do line wrapping?

Quote:

>I wonder if part of that has to do with lack of documentation.
>If we could add full text searches of module documentation to
>VoP or the hypothetical CPyAN,  it might make things easier..

<grin>  That's easy, as long as VoP extracts the module documentation to
HTML pages.  See http://www.*-*-*.com/

(Disclaimer: I'm a founder.  But most of the code is Python. ;-)
--

Androgynous poly {*filter*} vanilla {*filter*} het    <*>     http://www.*-*-*.com/
Hugs and backrubs -- I break Rule 6

Nostalgia just ain't what it used to be



Wed, 31 Jul 2002 03:00:00 GMT  
 How to do line wrapping?
In Python 1.5.1 (debian slink) the command
   >>> import glob
gives:
   ImportError: No module named glob
However the module is mentioned in the library reference.
The same thing happens with fnmatch.
Is there any particular reason for these absences ?  
egbert
--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991
========================================================================


Wed, 31 Jul 2002 03:00:00 GMT  
 How to do line wrapping?

Quote:

> In Python 1.5.1 (debian slink) the command
>    >>> import glob
> gives:
>    ImportError: No module named glob
> However the module is mentioned in the library reference.
> The same thing happens with fnmatch.
> Is there any particular reason for these absences ?

yes.  your installation is broken.

(look for glob.py and fnmatch.py.  if they're
not on the machine, complain to the debian
maintainers)

</F>



Wed, 31 Jul 2002 03:00:00 GMT  
 How to do line wrapping?

Quote:

> In Python 1.5.1 (debian slink) the command
>    >>> import glob
> gives:
>    ImportError: No module named glob
> However the module is mentioned in the library reference.
> The same thing happens with fnmatch.
> Is there any particular reason for these absences ?  
> egbert

If you still have the .deb, see if you can see any mention of a file named
"glob.py" inside it. If not, then, as much as I love debian, they screwed
up. In any case, I'm of the firm (if unpopular) opinion that installing
Python from the sources is very easy and usually much better for Linux
users. But then again, my production Python is ~ the latest CVS version,
so you might not want to listen to me.
--

INTERNET: Learn what you know.
Share what you don't.


Wed, 31 Jul 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Line wrapping

2. Line wrapping in listboxes?

3. Edit field line wrapping

4. Line Wrapping

5. Line-wrap test

6. Wrapping long lines

7. disable line wrap in xterm??

8. Recognizing wrapped lines

9. line wrapping in news messages

10. Scrolling wrapped lines

11. textbox scrolling malfunctions with wrapped lines

12. wanted: tcl proc to wrap lines of text

 

 
Powered by phpBB® Forum Software