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
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
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
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
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 #
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
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
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
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
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.
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',
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
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
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
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
15 matches
Mail list logo