looping over the files in a directory

Elaine Jackson elainejackson7355 at home.com
Fri May 14 21:04:40 EDT 2004


Works like a charm. Thanks for the tip.

"Mark J. Nenadov" <mark at freelance-developer.com> wrote in message
news:pan.2004.05.14.16.17.33.273871 at freelance-developer.com...
| 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