When a try execute this code in a def, returns: ValueError: max() arg is an empty sequence
But when a execute line by line works The files in directory are xlsx named "YYYY-MM-DD Matinal"
import os
from os.path import getmtime
from pathlib import Path
path_matinal=os.path.abspath(r'C:\Users\garibeiro\Documents')
def path():
directory = Path(path_matinal)
files = directory.glob('*.xlsx')
matinal = max(files, key= getmtime)
print(matinal)