Iterating all files in a directory

Laura Creighton lac at strakt.com
Sun Jan 26 02:29:44 CET 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