tags:

views:

111

answers:

5

Can’t be hard, but I’m having a mental block.

+6  A: 

glob.glob or os.listdir

Tuomas Pelkonen
+6  A: 
import os
os.listdir("path") # returns list
Jaysus, `listdir`. Mental block lifted, thank you kindly.
Paul D. Waite
A: 

os module handles all that stuff.

zdav
+5  A: 

One way:

import os
os.listdir("/home/username/www/")

Another way:

glob.glob("/home/username/www/*")

Examples found here.

The glob.glob method above will not list hidden files.

Trey
+1  A: 

os.walk can be used if you need recursion:

import os
for path,dirs,files in os.walk('.'):
    for fn in files:
        print os.path.join(path,fn)
Mark Tolonen