This helps wrap the inline directory going to a function that gives only full file paths. Then you can simply take the function that returns all the files and select the one that has the longest modification time:
import os def all_files_under(path): """Iterates through all files that are under the given path.""" for cur_path, dirnames, filenames in os.walk(path): for filename in filenames: yield os.path.join(cur_path, filename) latest_file = max(all_files_under('root'), key=os.path.getmtime)
Ants aasma
source share