Permissions or mutable objects... Read only file contents template to write only?

Gavin Tomlins gavin at madzag.com
Mon Feb 12 06:07:49 EST 2001


Greetings

I'm currently faced with a problem regarding permissions. I'm trying to read in 
x# of template files to construct an output file.

eg.

templateHdr.txt
templateFooter.txt
outputResult.txt

I attempt to read in the files then  redirect the inputted template to the 
output file ergo,

cTemplateHdr = "templateHdr.txt"
cTemplateFooter = "templateFooter.txt"
cOutput = "outputResult.txt"

#open files for various operations
fileHdr = open(cTemplateHdr, "r")
fileFooter = open(cTemplateFooter, "r')
fileOutput = open(cOutput, "w")

cTempStr = ""
cTempStr = fileHdr.readlines()

fileOutput.write(cTempStr)

at this point I am presented with a type error indicating that I'm trying to 
write a 'read buffer'.

What is the process for rectifying this problem. Any assistance, reference 
would be greatly appreciated. I've searched the Python documentation but was 
unable to find appropriate documentation. If possible, could people cite the 
reference for my understanding. I can only put it down to lack of comprehension 
or poor choice of search criteria on my behalf.

Regards

Gavin

gavin at madzag.com



More information about the Python-list mailing list