On Jul 8, 2008, at Jul 8:8:08 PM, Ben Keshet wrote:
I want to use a 'for' iteration to manipulate files in a set of
folders, something like:
folders= ['1A28','1A6W','56Y7']
for x in folders:
print x # print the current folder
f = open('my/path/way/x/my_file.txt', 'r')
...
I think:
f = open('my/path/way/%s/my_file.txt' % x, 'r')
should work, although I would probably be more clear about the names,
like:
folders=['1A28','1A6W','56Y7']
for folder in folders:
filename='my/path/way/%s/my_file.txt' % x
fid=open(filename,'r')
....
also, make sure that you do mean the relative path my/path/way/...
# in current folder
as opposed to the absolute path: /my/path/way
# in root folder
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list