Printing current time to a file

skip at pobox.com skip at pobox.com
Thu Nov 10 21:48:49 EST 2005


    zolaris> self.log.write(time.ctime(time.time()))

    zolaris> But that prints nothing in the file assigned to log.  Is there
    zolaris> something I should be doing extra?

There's no newline in there. You probably need to flush the file:

    self.log.write(time.ctime(time.time()))
    self.log.flush()

You might want to write a newline after the time as well.  If the logfile is
line-buffered that will also provoke a flush.

Skip




More information about the Python-list mailing list