Yep it works! I understand now it iterates on each line and replaces the old elements with the new ones. In the end you get the latest date of the last line of log.
I will work on the exception handling and other refinements. Thanks. On Tue, Oct 27, 2009 at 8:41 AM, Christian Witts <cwi...@compuscan.co.za>wrote: > > >> for line in open(log_file): >> last_log_date = ' '.join(line.split(' ')[:3] >> >> which would take the first 3 elements in your list and combine >> them again. Of course this is again just a simple representation >> of what to do. >> >> -- Kind Regards, >> Christian Witts >> >> >> >> >> >> -- >> Best Regards, >> bibimidi >> >> Sent from Riyadh, 01, Saudi Arabia >> > > > Hi Bibi, > > Yeah there was a missing parenthesis, I was just typing away. > As for knowing if you're on the last line of your log file, basically what > will happen is for every line you iterate through it will parse the first 3 > elements of your line and use that for the last_log_date. > If you know for certain that every line will start with the time stamp then > it will work fine, if that is not the case then you will need to build in > some checking to ensure you get the correct information. > > -- > Kind Regards, > Christian Witts > > > -- Best Regards, bibimidi
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor