[Tutor] Brain Dead
Fri, 11 Aug 2000 12:47:43 -0700 (PDT)
On Fri, 11 Aug 2000 email@example.com wrote:
> I appreciate your help. This is the code I wrote.
> import string
> myfile = open('master.hosts', 'r')
> for line in myfile.readlines():
> line = string.replace(line, '#', ';')
> if '\t' in line:
> line = string.replace(line, string.whitespace, 't\n\r\v\f')
> fields = string.split(line)
> if ';' in fields:
> newline = ';' + fields + '\t\tA\tIN\t' +
> newline = fields + '\t\tA\tIN\t' + fields
> print newline
Right now, all the results get printed out by that 'print' statement.
I'm guessing that instead of just printing out newline, you want to write
newline into your myfile. You can do this by replacing the print call
with a write call.
should do the trick.