os.walk question
alex23
wuwei23 at gmail.com
Wed Jul 23 03:06:31 EDT 2008
On Jul 24, 11:52 am, "Lanny" <la... at freshells.ch> 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.
So you -only- want the files from one directory?
Try: _, _, files = os.walk('/top/folder/here').next()
The single underscore is a convention to indicate we don't care about
those results.
The .next() is needed to step through os.walk once, which will start
at the path you specify.
Hope this helps.
- alex23
More information about the Python-list
mailing list