SyntaxFix
Write A Post
Hire A Developer
Questions
I've been using this in Python 3, including pattern matching on the filename.
from pathlib import Path def latest_file(path: Path, pattern: str = "*"): files = path.glob(pattern) return max(files, key=lambda x: x.stat().st_ctime)