[Tutor] Add newline's, wrap, a long string

David david at abbottdavid.com
Wed Apr 29 14:54:53 CEST 2009

David wrote:
> Martin Walsh wrote:

>> Just one more comment, string.join is deprecated, yet join is a method
>> of str objects. So ...
>>       Lines = '\n'.join(L)
>> ... or use textwrap.fill which returns a string with the newlines
>> already in place ...
>>       Lines = textwrap.fill(USE, 80)
>> HTH,
>> Marty
> Again thanks, I like the comments :)
> -david

Ok here is what I have now;

import textwrap

def get_use():
     fname = open('/tmp/comprookie2000/emerge_info.txt')
     for line in fname:
         if 'USE' in line:
             output = line.split('"')[1]
             USE = textwrap.fill(output, 80)
             USE = ''


Here is the whole program so far, what it does is it logs into a druple 
web site and posts. I would like to make it better, as you can see I do 
the same thing over and over. Also I don't think this is a python 
problem but I can only post one line or I get HTTP/1.1 417 Expectation 
Failed. I thought the problem was because it was one long string, but 
that is solved, may be it is looking for return/Enter to be pressed, not 



Powered by Gentoo GNU/Linux

More information about the Tutor mailing list