Iterating all files in a directory

Laura Creighton lac at strakt.com
Sat Jan 25 20:29:44 EST 2003


> How can iterate through all the files in a directory?
> 
> ie. obtain a list of all the file's name 
> 
> Thanks.

>>> from os import listdir
>>> listdir('/tmp')
['.font-unix', '.gdm_socket', '.X11-unix', '.ICE-unix', '.X0-lock', 'ssh-XXCg2xlC', 'kde-lac', 'ksocket-lac', '.fam_socket', 'dcopWthjI2', 'mcop-lac', 'oo_branches.pdf', 'userguide.pdf']
>>>





More information about the Python-list mailing list