Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import os
  2.  
  3. def findFilesRecursively(path, pred = None, ls = None):
  4. if not ls:
  5. ls = []
  6.  
  7. for p in os.listdir(path):
  8. p = os.path.join(path, p)
  9. if os.path.isdir(p):
  10. findFilesRecursively(p, pred, ls)
  11. elif os.path.isfile(p):
  12. if not pred or pred(p):
  13. ls.append(p)
  14.  
  15. return ls
  16.  
  17. ls = findFilesRecursively(os.getcwd(), lambda x: x.endswith('.py'))
  18. for f in ls:
  19. print(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement