[Tutor] file I/O

charlie derr webmindforever@organicmeat.net
Wed, 11 Jul 2001 16:49:41 -0400


Not sure.  It seems to work fine in idle (2.1 on NT) if i remove the blank
line you have on line 2.

	~c

+-----Original Message-----
+From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
+kevin parks
+Sent: Wednesday, July 11, 2001 3:57 PM
+To: tutor@python.org
+Subject: [Tutor] file I/O
+
+
+Hi. I am a little confused as to why this hangs when i run it. I
+am trying to make a script that opens a file for input opens a
+file for writing and reads in a line from the input and copies it
+to the created output file. In this case except for  the start
+here and EOF lines the file should be an exact copy. (the point is
+that later i an going to do something to each line of text), but i
+have to get this much working, plus the other business i mentioned
+on UNIX and Mac paths, but first this, Why does it just hang the
+interpreter?
+
+This is in Mac OS 9.bloat Python 2.1 IDE
+
+
+def finout():
+
+	infilename = raw_input('Enter in file name: ')
+	infile = open(infilename, 'r')
+	f = open('sys:scripts:foo.txt', 'w')
+	f.write("start here\n\n")
+	done = 0
+	while not done:
+		aLine = infile.readline()
+		if aLine != " ":
+			f.write(aLine + '\n')
+		else:
+			done = 1
+	infile.close()
+	f.write("\n\nEOF\n")
+	f.close()
+
+if __name__ == '__main__':
+	finout()
+
+
+
+
+Get 250 color business cards for FREE!
+http://businesscards.lycos.com/vp/fastpath/
+
+_______________________________________________
+Tutor maillist  -  Tutor@python.org
+http://mail.python.org/mailman/listinfo/tutor
+