[Tutor] Regex for Filesystem path

Mats Wichmann mats at wichmann.us
Tue Nov 6 14:07:56 EST 2018


>>    4) look for the latest file in the directory  /a/b/c/d/test/123456/789
> 
> Slightly more complex, you need the creation timestamp.
> You can find that with os.path.getctime() (or several
> other options, eg os.stat)

here's a trick you might be able to make use of:

somelist = generate-list-of-files-in-directory
newest = max(somelist, key=os.path.getctime)




More information about the Tutor mailing list