would suggest using glob.iglob() instead of the glob.glob(), as it is more efficient.
glob.iglob() Return an iterator which yields the same values as glob() without actually storing them all simultaneously.
Which means glob.iglob() will be more efficient.
I mostly use below code to find the latest file matching to my pattern:
LatestFile = max(glob.iglob(fileNamePattern),key=os.path.getctime)
Hope this work!!
If you need to learn more about Python, It's recommended to join Python Training today.