help me to find the error
contact at xavierho.com
Fri Jul 10 05:53:15 EDT 2009
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.
If you leave it to:
*and then assign another variable to the readlist, such as:
*lines = f0.readlines()*
Then in the for loop, change f1 to
That may just stop it from complaining.
Untested, but logically it's sound.
Hope that works,
Ching-Yun "Xavier" Ho, Technical Artist
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: contact at xavierho.com
On Fri, Jul 10, 2009 at 5:41 PM, jhinak sen <jhinak.sen at gmail.com> wrote:
> i am a beginner in python language,
> i am trying with this programme :
> to find the addition and mean from a data set in a file and writing the
> mean and sum in some other file :
> *#! /usr/bin/env python
> import re
> import cPickle as p
> import math
> from numpy import *
> f0= open("temp9","r+").readlines()
> f2= open("out1","r+")
> add_1=[ ];
> for i in range(0, len(f0)):
> add= float(f1)+float(f1)
> mean= float(add)/2
> print (f1).ljust(6) ,(f1).ljust(6),repr(add).ljust(7),
> f2.write("%s" % repr(add).ljust(7)),f2.write("%s" %
> print "printing from file"
> for i in range(0, len(add_1),2):
> print add_1[i]," ", add_1[i+1]
> and this programme is givving me this error :
> "" *Traceback (most recent call last):
> File "./temporary1.py", line 24, in <module>
> AttributeError: 'list' object has no attribute 'close'*
> please help to to find the error.
> or suggest some simpler or better way
> 1)file "temp9" is already exist
> 2)this programme is giving me all my outputs, but at the end of the out
> ..its giving me that error.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list