Re: a simple 'for' question

2008-07-10 Thread Ethan Furman
Tim Roberts wrote: Ethan Furman <[EMAIL PROTECTED]> wrote: Ben Keshet wrote: it didn't help. it reads the pathway "as is" (see errors for both tries). It looks like it had the write pathway the first time, but could not find it because it searched in the path/way instead of in the path\w

Re: a simple 'for' question

2008-07-10 Thread Tim Roberts
Ethan Furman <[EMAIL PROTECTED]> wrote: >Ben Keshet wrote: >> it didn't help. it reads the pathway "as is" (see errors for both >> tries). It looks like it had the write pathway the first time, but >> could not find it because it searched in the path/way instead of in the >> path\way. thanks

Re: a simple 'for' question

2008-07-09 Thread Ethan Furman
Ben Keshet wrote: it didn't help. it reads the pathway "as is" (see errors for both tries). It looks like it had the write pathway the first time, but could not find it because it searched in the path/way instead of in the path\way. thanks for trying. The form of slash ('\' vs '/') is irre

Re: a simple 'for' question

2008-07-09 Thread Bruno Desthuilliers
Tim Cook a écrit : On Wed, 2008-07-09 at 00:00 -0400, Ben Keshet wrote: oops, my mistake, actually it didn't work... when I tried: for x in folders: print x # print the current folder filename='Folder/%s/myfile.txt' %x f=open(filename,'r') it says: IOError: [Errno 2] No such fil

Re: a simple 'for' question

2008-07-09 Thread Ben Keshet
it didn't help. it reads the pathway "as is" (see errors for both tries). It looks like it had the write pathway the first time, but could not find it because it searched in the path/way instead of in the path\way. thanks for trying. folders= ['1','2','3'] for x in folders: print x #

Re: a simple 'for' question

2008-07-09 Thread cokofreedom
On Jul 9, 2:08 am, Ben Keshet <[EMAIL PROTECTED]> 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_fi

Re: a simple 'for' question

2008-07-09 Thread Tim Cook
On Wed, 2008-07-09 at 00:00 -0400, Ben Keshet wrote: > oops, my mistake, actually it didn't work... > when I tried: > for x in folders: > print x # print the current folder > filename='Folder/%s/myfile.txt' %x > f=open(filename,'r') > > it says: IOError: [Errno 2] No such file or

Re: a simple 'for' question

2008-07-08 Thread Ben Keshet
oops, my mistake, actually it didn't work... when I tried: for x in folders: print x # print the current folder filename='Folder/%s/myfile.txt' %x f=open(filename,'r') it says: IOError: [Errno 2] No such file or directory: 'Folder/1/myfile.txt' I should mention that I am working in

Re: a simple 'for' question

2008-07-08 Thread Ben Keshet
thanks for the reply - it worked. I just want to make sure that I understand the general syntax - when can I use the iteration variable as x (e..g. print x), and when do I need to use the ...%s... %x syntax? is it only when I need to call x as a "string"? I am not sure I am asking the questio

Re: a simple 'for' question

2008-07-08 Thread John McMonagle
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.

Re: a simple 'for' question

2008-07-08 Thread Rajanikanth Jammalamadaka
Thanks for correcting my typo norseman. Ben: I forgot a slash after the first string as norseman pointed out. Raj On Tue, Jul 8, 2008 at 5:51 PM, norseman <[EMAIL PROTECTED]> wrote: > > Almost correct: There is a typo. Should read: > > for x in folders: >open('my/path/way/'+x+'/myfile.txt',

Re: a simple 'for' question

2008-07-08 Thread norseman
Almost correct: There is a typo. Should read: for x in folders: open('my/path/way/'+x+'/myfile.txt','r') Rajanikanth Jammalamadaka wrote: Hi! Try this for x in folders: open('my/path/way'+x+'myfile.txt','r') Cheers, Raj On Tue, Jul 8, 2008 at 5:08 PM, Ben Keshet <[EMAIL PROTECT

Re: a simple 'for' question

2008-07-08 Thread Brian Blais
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 t

Re: a simple 'for' question

2008-07-08 Thread Rajanikanth Jammalamadaka
Hi! Try this for x in folders: open('my/path/way'+x+'myfile.txt','r') Cheers, Raj On Tue, Jul 8, 2008 at 5:08 PM, Ben Keshet <[EMAIL PROTECTED]> wrote: > Hi fans, > > I want to use a 'for' iteration to manipulate files in a set of folders, > something like: > > folders= ['1A28','1A6W','56Y7

a simple 'for' question

2008-07-08 Thread Ben Keshet
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') ... where 'x' in the pathway should iterate over '1A28