[Tutor] Sorting specific files by modification date

Kent Johnson kent37 at tds.net
Tue Nov 6 04:41:34 CET 2007

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=lambda f: os.stat(f).st_mtime)

I would probably write it that way myself, I used the def cuz I think it 
is a bit easier to understand.


> On 11/5/07, *Kent Johnson* <kent37 at tds.net <mailto:kent37 at tds.net>> wrote:
>     def fileTime(f):
>        return os.stat(f).st_mtime
>     newest = max(first_files, key=fileTime)
>     Kent

More information about the Tutor mailing list