[Tutor] getting the last file in a folder (reliably)

Steven D'Aprano steve at pearwood.info
Wed Mar 23 12:49:02 CET 2011


Peter Otten wrote:
> Steven D'Aprano wrote:
> 
>> files.sort()
>> the_file_name = files[-1]
> 
> You don't need to sort if you want only one file:
> 
> the_file_name = max(files)


Nice catch!



-- 
Steven


More information about the Tutor mailing list