from pathlib import Path m = list(Path('.').rglob('*.py')) for f in m: print(f)