from os import listdir
from os.path import isfile, join
only_files = [f for f in listdir(my_path) if isfile(join(my_path, f))]
import pathlib
only_files = [f for f in pathlib.Path(my_path).iterdir() if f.is_file()]
from os import walk
only_files = []
for (dirpath, dirnames, filenames) in walk(my_path):
only_files.extend(filenames)
break