log = open('log.txt', 'w') print >> log, 1, 2, 3 print >> log, 4, 5, 6 log.close( ) print 7, 8, 9 print open('log.txt').read( )