Ben Keshet wrote:
> Hi fans,
>
> 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')
> ...
>
Use os.path.join
import os
folders = ['1A2B', '1A6W', '56Y7']
for x in folders:
f = open(os.path.join('my/path/way', x, 'my_file.txt'), 'r')
--
http://mail.python.org/mailman/listinfo/python-list
