I need a file system walker that I could instruct to ignore traversing directories that I want to leave untouched, including all subdirectories below that branch. The os.walk and os.path.walk just don't do it.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Actually,
os.walk
may do exactly what you want. Say I have a list (perhaps a set) of directories to ignore inignore
. Then this should work:It is possible to modify the second element of
os.walk
's return values in-place:Now, you can just hand in a predicate for subdirectories:
Here's the best and simple solution.
Remember, if you remove the folder name from dirs, it won't be explore by os.walk.
hope it helps
So I made this home-roles walker function: