looping over the files in a directory
Mark J. Nenadov
mark at freelance-developer.com
Fri May 14 12:17:34 EDT 2004
On Fri, 14 May 2004 15:32:32 +0000, Elaine Jackson wrote:
> Can anyone please tell me the actual syntax for saying something like this:
>
> for <file> in <directory>:
> <do something with the file>
A simple example:
import os
path = '/home/bob/'
for f in os.listdir(path):
print f
--
Mark J. Nenadov
Python Byte Solutions
http://www.pythonbyte.com/
More information about the Python-list
mailing list