os.walk
in python when used on /
directory descends into /Volumes
and starts traversing external drives. How can I traverse all directories without leaving current filesystem?
Asked
Active
Viewed 47 times
3

John Kugelman
- 349,597
- 67
- 533
- 578

Marcin
- 7,874
- 7
- 45
- 49
-
1You could write a custom recursive traversal using ```os.listdir()``` – Abhinav Mathur Apr 13 '21 at 04:29
-
How do I know I'm still on the same filesystem? – Marcin Apr 13 '21 at 04:34
-
1this might help: https://stackoverflow.com/questions/19859840/excluding-directories-in-os-walk – KetZoomer Apr 13 '21 at 04:57
-
you can maybe make use of the `pathlib` module – Novus Edge Apr 13 '21 at 06:05