language agnostic - What are all the ways to traverse directory trees? -


How do you cope with the Directory Tree in your preferred language?

What do you need to do to locate a directory tree in different operating systems?

Python :

If you are trying a quick, clean and portable solution then:

  import os base_dir = '.' Def foo (arg, curr_dir, files): print curr_dir print files os.path.walk (base_dir, foo, none)  

Note that you just do something else instead You can modify foo name printing Also, if you are interested in migrating to Python 3.0, you will need to use os.walk () instead.


Comments