[BioPython] IOError: [Errno 2] No such file or directory:

Peter biopython at maubp.freeserve.co.uk
Sun Mar 4 17:34:26 UTC 2007


Hossein Shahsavari wrote:
 > I have another maybe simple question:
> 
> I have 26 files namely output1, output2,...,output26. I can read them 
> one by one but how can read them all by an easier way like a loop ?
 > I put a "for loop" by setting
> 
> i=1
> 
> for i in range(1,27)
> template='outputi'
> 
> however, I got the same error as above IOError: [Errno 2] No such file or
> directory: 'outputi'. It seems "i" can't be attached to the output.
> 
> Thanks alot
> 
> Hossein

You should really try a basic introduction to python.  There are lots of 
tutorials online, and great books too.  Your questions so far are not 
really related to BioPython at all.

Note that indentation is very important in python.  You were also 
missing the colon at the end for line.  More importantly the following 
line just sets the variable template to the string 'outputi', and 
doesn't do anything with the variable i.

template='outputi'

You want to do something like this:

for i in range(1,27) :
     template = 'output' + str(i)
     print template

Good luck.

Peter




More information about the Biopython mailing list