For those who came here looking for a solution to get the first file in a dir, using pathlib
import pathlib
my_dir = pathlib.Path("my/dir/")
first_file = next((x for x in my_dir.iterdir() if x.is_file()), None)
first_file
is None
if dir is empty