os.walk question

B execrable at gmail.com
Wed Jul 23 22:40:38 EDT 2008


Lanny wrote:
> How would one make a list of the files in the top directory
> using os.walk.
> 
> I need to pick a random file from said list.
> 
> Thanks. 
> 
> 
> 
> 
> -- Posted on news://freenews.netfront.net - Complaints to news at netfront.net --
> 

how about:

import os

x = os.walk('/')
(root,dirs,files) = x.next()



'files' should contain a list of filenames.



More information about the Python-list mailing list