import os
import os.path
for dirpath, dirnames, filenames in os.walk("."):
for filename in [f for f in filenames if f.endswith(".log")]:
print os.path.join(dirpath, filename)
import os
from glob import glob
files = []
start_dir = os.getcwd()
pattern = "*.log"
for dir,_,_ in os.walk(start_dir):
files.extend(glob(os.path.join(dir,pattern)))
import os
path_list = [os.path.join(dirpath,filename) for dirpath, _, filenames in os.walk('.') for filename in filenames if filename.endswith('.log')]
from pathlib import Path
working_dir = Path()
for path in working_dir.glob("**/*.log"):
print(path)
# OR if you need absolute paths
print(path.absolute())
# OR if you need only filenames without extension for further parsing
print(path.stem)