Feed on
Posts
Comments

how to do ls in python


glob is a handy way to do a directory listing in python.

for instance, to return a list of all the text files in a directory, you could command:

import glob

glob.glob(“/mypath/*.txt”)

(glob handles *,?, and [] matching).


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.