Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def findFilesRecursively(path, pred = None, ls = None):
- if not ls:
- ls = []
- for p in os.listdir(path):
- p = os.path.join(path, p)
- if os.path.isdir(p):
- findFilesRecursively(p, pred, ls)
- elif os.path.isfile(p):
- if not pred or pred(p):
- ls.append(p)
- return ls
- ls = findFilesRecursively(os.getcwd(), lambda x: x.endswith('.py'))
- for f in ls:
- print(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement