for current_dir, dirs, files in os.walk(workspace):
if current_dir.endswith("IgnoreMe"):
continue #skip this folder
for file in files:
if file.endswith(".asc"):
rasters[file].append(os.path.join(root, file))
more specifically for you
for current_dir, dirs, files in os.walk(workspace):
if "_" not in os.path.split(current_dir)[-1]:
#filter out all ".asc" files
files = filter(lambda fname:not fname.endswith("asc"),files)
for file in files:
#these dont have any more ".asc" files