[Tutor] file.write() blocking

Isr Gish isrgish at fastem.com
Thu Mar 25 01:23:00 EST 2004


What seems to be wrong here is, that you are using file.write() but you don't have a file object named file. (which anyway would be a bad idea). Your file object is called output_file, therefore you should do output_file.write("")


-----Original Message-----
   >From: "Jonathan Hayward"<jsh47 at cam.ac.uk>
   >Sent: 3/24/04 8:46:08 AM
   >To: "tutor at python.org"<tutor at python.org>
   >Subject: [Tutor] file.write() blocking
   >
   >    def save_entry(self, text, filename):
   >        debug_log("Reached 1")
   >        debug_log(DOCUMENT_ROOT + "entries/" + filename)
   >        output_file = file(DOCUMENT_ROOT + "entries/" + filename, "w")
   >        debug_log("Reached 2")
   >        #debug_log(text)
   >        file.write("")
   >        debug_log("Reached 2.5")
   >        file.write(text)
   >        debug_log("Reached 3")
   >        file.close()
   >        debug_log("Reached 4")
   >
   >When I get to this point in my code, it prints, "Reached 2" and hangs on 
   >file.write(""). The output directory has a zero-byte file created. When 
   >I try analogous test code from Python interactively, it works; does 
   >anyone see the glitch in this? (The text is a small webpage.)
   >
   >-- 
   >++ Jonathan Hayward, jonathan.hayward at pobox.com
   >** To see an award-winning website with stories, essays, artwork,
   >** games, and a four-dimensional maze, why not visit my home page?
   >** All of this is waiting for you at http://JonathansCorner.com
   >
   >
   >
   >_______________________________________________
   >Tutor maillist  -  Tutor at python.org
   >http://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list