On Sun, 02 Sep 2012 14:04:29 -0400, Terry Reedy
wrote:
>If you process each line separately, there is no reason to read them all
>at once. Use the file as an iterator directly. Since line is already a
>string, there is no reason to copy it into a new string. Combining these
>two changes with Ma
On 9/2/2012 6:36 AM, Gilles wrote:
On Sun, 02 Sep 2012 12:19:02 +0200, Gilles wrote:
(snip)
Found it:
#rewrite lines to new file
output = open('output.txt','w')
for line in textlines:
#edit each line
line = "just a test"
output.write("%s" % line)
output.close()
If y
On 02/09/2012 11:36, Gilles wrote:
On Sun, 02 Sep 2012 12:19:02 +0200, Gilles wrote:
(snip)
Found it:
#rewrite lines to new file
output = open('output.txt','w')
for line in textlines:
#edit each line
line = "just a test"
output.write("%s" % line)
output.close()
IMH
On Sun, 02 Sep 2012 12:19:02 +0200, Gilles wrote:
(snip)
Found it:
#rewrite lines to new file
output = open('output.txt','w')
for line in textlines:
#edit each line
line = "just a test"
output.write("%s" % line)
output.close()
--
http://mail.python.org/mailman/listinfo
Hello
This is a newbie question.
I need to read a text file into a variable, loop through each line and
use a regex to substitute some items within the line, and save the
whole variable into a new text file.
This triggers an error when I save the modified variable that contains
all the lines:
==