import pathlib # define the path currentDirectory = pathlib.Path('.') # define the pattern currentPattern = "*.py" for currentFile in currentDirectory.glob(currentPattern): print(currentFile)