Alessandro wrote:

> - until now, the only solution which works is to repeat the code while
> the file is still open, which means a quite redundant code:
> 
> linestring = open(path, 'r').read()
> i=linestring.index("*NODE")
> i=linestring.index("E",i)
> e=linestring.index("*",i+10)
> textN = linestring[i+2:e-1] # crop the ELement+nodes list
> Nfile = open("N.txt", "w")
> Nfile.write(textN)
> 
> linestring = open(path, 'r').read()
> i=linestring.index("*NODE")
> i=linestring.index("E",i)
> e=linestring.index("*",i+10)
> textN = linestring[i+2:e-1] # crop the ELement+nodes list
> Nfile = open("N.txt", "w")
> Nfile.write(textN)

Is this the complete script? The only effect of the second copy of your code 
above is that it implicitly closes the first Nfile. Otherwise it is cargo 
cult.

Peter 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to