: : I am developing a program which requires the capability to go through all the files, etc in a set user(determined at user's login, usually their own) and send the results to other modules. I am using Python 2.3 as 2.4 has strange problems with modules like pygame, etc.
: :
: : Anyway, I found os.walk() and I tried using it, but all I get is a "<generator function at (some hex address)>". I even tried using the examples given in the default help file, but it doesn't work. I was wondering how to properly use os.walk, but any further info would be greatly appreciated.
: :
: : BTW, the help with the SHA module was invaluable, so thanx to all that helped!
: :
:
: Suppose the /tmp directory contains:
:
: /tmp
: /alfa
: one.txt
: two.txt
: /beta
: /gamma
: three.txt
: four.txt
: five.txt
:
:
: With this code:
:
: import os
: dir_list = os.walk('/tmp')
: for i in dir_list:
: print i
:
:
: You'll recieve:
:
: ('/tmp', ['alfa', 'beta'], ['five.txt'])
: ('/tmp/alfa', [], ['one.txt', 'two.txt'])
: ('/tmp/beta', ['gamma'], ['four.txt'])
: ('/tmp/beta/gamma', [], ['three.txt'])
:
:
: That's a tuple on each run containing the actual path (as a string), the subdirectories (in a list) and the files (in a list) on that level in the filesystem...
:
: os.walk()'s other parameters are well described in the manual.
:
: Hope this helps
:
: Drost
:
Don't worry. I just looked up generators and found the .next() command associated with them. That allowed me to use a recursive function to crawl through ALL files. But thank you for helping.