[Tutor] Re: Tutor digest, Vol 1 #950 - 12 msgs

kevin parks kp87@lycos.com
Thu, 12 Jul 2001 06:58:27 +0900


The new way:

for aLine in infile.xreadlines() :
f.write( aLine )

does indeed work on Mac Python 2.1. This little script copies a file exactly

boksa('infile', 'outfile')


def boksa(infilename, outfilename):
	infile = open(infilename, 'r')
	f = open(outfilename, 'w')
	for aLine in infile.xreadlines() :
		f.write( aLine )
	infile.close()
	f.close()

if __name__ == '__main__':
	boksa()


Now i can use f.readline()[:-1] also to change line endings, no? But doesn't DOS use both carriage return and newline? so wouldn't you have to use: f.readline()[:-2] in case of DOS?

Anyway it works (unless there is yet another bug i don't see) and it is so small!

cheers,
kevin parks
seoul, korea
kp87@lycos.com




Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/