I\'m writing a program that will parse an Apache log file periodically to log it\'s visitors, bandwidth usage, etc..
The problem is, I don\'t want to open the log an
Here is code proving using the length sugestion of yours and the tell methond:
beginning="""line1
line2
line3"""
end="""- The log will open from this point
line4
line5"""
openfile= open('log.txt','w')
openfile.write(beginning)
endstarts=openfile.tell()
openfile.close()
open('log.txt','a').write(end)
print open('log.txt').read()
print("\nAgain:")
end2 = open('log.txt','r')
end2.seek(len(beginning))
print end2.read() ## wrong by two too little because of magic newlines in Windows
end2.seek(endstarts)
print "\nOk in Windows also"
print end2.read()
end2.close()