I'm new to Python myself, but I think it's because the method readlist() returns a list. Hence, f0 is typed 'list'. And lists can't be closed.<br><br>If you leave it to:<br><br><b>f0= open("temp9","r+")<br>
<br></b>and then assign another variable to the readlist, such as:<br><br><b>lines = f0.readlines()</b><br><br>Then in the for loop, change f1 to<br><br><b>f1=lines[i].split()</b><br><br>That may just stop it from complaining.<br>
<br>Untested, but logically it's sound.<br><br>Hope that works,<br><br clear="all">Ching-Yun "Xavier" Ho, Technical Artist<br><br>Contact Information<br>Mobile: (+61) 04 3335 4748<br>Skype ID: SpaXe85<br>Email: <a href="mailto:contact@xavierho.com">contact@xavierho.com</a><br>
Website: <a href="http://xavierho.com/">http://xavierho.com/</a><br>
<br><br><div class="gmail_quote">On Fri, Jul 10, 2009 at 5:41 PM, jhinak sen <span dir="ltr"><<a href="mailto:jhinak.sen@gmail.com">jhinak.sen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hi,<br>i am a beginner in python language,<br><br>i am trying with this programme :<br>to find the addition and mean from a data set in a file and writing the mean and sum in some other file :<br>""<br><b>#! /usr/bin/env python<br>

<br>import re<br>import cPickle as p<br>import math<br>from numpy import *<br><br>f0= open("temp9","r+").readlines()<br>f2= open("out1","r+")<br>add_1=[ ];<br>for i in range(0, len(f0)):<br>

        f1=f0[i].split()<br>        add= float(f1[1])+float(f1[2])<br>    mean= float(add)/2<br>        print (f1[1]).ljust(6) ,(f1[2]).ljust(6),repr(add).ljust(7), repr(mean).ljust(7)<br>        add_1.append(add)<br>    add_1.append(mean)<br>

        f2.write("%s" % repr(add).ljust(7)),f2.write("%s" % repr(mean).ljust(7))<br>print "printing from file"<br>for i in range(0, len(add_1),2):<br>        print add_1[i],"        ", add_1[i+1]<br>

<br>f0.close()<br>f2.close()</b><br><br><br>""<br><br>and this programme is givving me this error :<br><br>""    <b>Traceback (most recent call last):<br>  File "./temporary1.py", line 24, in <module><br>

    f0.close()<br>AttributeError: 'list' object has no attribute 'close'</b><br>""<br><br>please help to to find the error.<br>or suggest some simpler or better way<br><br>note:  <br>1)file "temp9" is already exist<br>

2)this programme is giving me all my outputs, but at the end of the out ..its giving me that error.<br>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>