Re: [Tutor] Sorting specific files by modification date

2007-11-05 Thread Kent Johnson
Fiyawerx wrote: > Thanks Kent, thats just what I needed, but got stuck in a single mode of > thought trying to do it inline, didn't even think of adding a separate > function since the program seemed 'too simple'. You can always use a lambda if you like that style: newest = max(first_files, key=

Re: [Tutor] Sorting specific files by modification date

2007-11-05 Thread Kent Johnson
Fiyawerx wrote: > first_files = [ file for file in data['xls_files'] if u'First Worksheet' > in xlrd.open_workbook(file).sheet_names() ] > data['first_file'] = ?? > This is where I get stuck, I'm trying to figure out how, from the files > that match, I can select the file with the most current t

Re: [Tutor] Sorting specific files by modification date

2007-11-05 Thread Michael Langford
In psudocode: #map the files to their time. filesByTimes = {} for each in filesInDirectory: filesByTimes[os.stat(each).st_mtime]=each #find the largest time times = filesByTimes.keys() sort(times) #retrieve the file that goes with it latestFile = filesByTimes[times[-1]] --Michael On

[Tutor] Sorting specific files by modification date

2007-11-05 Thread Fiyawerx
I'm working on a small script that so far, using the xlrd module, ( http://www.lexicon.net/sjmachin/xlrd.html) will parse all the files in a given directory for a xls file with a specific worksheet. This way, if the file names change, or people don't save the spreadsheet with the right name, my scr

[Tutor] [Fwd: Re: reading and writing with csv then appending some data to a specific line]

2007-11-05 Thread Kent Johnson
Forwarding to the list... Original Message Subject:Re: [Tutor] reading and writing with csv then appending some data to a specific line Date: Mon, 5 Nov 2007 14:54:49 +0100 From: pierre cutellic <[EMAIL PROTECTED]> To: Kent Johnson <[EMAIL PROTECTED]> References:

Re: [Tutor] difflib.SequenceMatcher with get_matching_blocks is incorrect

2007-11-05 Thread Tom
Hi, I asked this question last year but got no response. I'm trying to write a program to test someone's typing speed and show them their mistakes. However I'm getting weird results when looking for the differences in longer (than 100 chars) strings: import difflib # a tape measure string (just

Re: [Tutor] import and reload in modules

2007-11-05 Thread Kent Johnson
Garry Willgoose wrote: > In response to Kent's suggestion here is an updated post showing the > python code and the error log. The original reason for using try was > I thought maybe this was scoping problem and that maybe 2nd time > through the call it needed to import it again from scratch.