[Tutor] attribute error - quick addition
Sara Johnson
sarliz73 at yahoo.com
Mon Jul 30 23:13:50 CEST 2007
Thanks Alan and Kent (for the sorting notes)!
Alan...I guess I thought outfile2 had data. { i.e., outfile2=open('missmeas.dat','w') }
My mistake.
Thanks,
Sara
----- Original Message ----
From: Alan Gauld <alan.gauld at btinternet.com>
To: tutor at python.org
Sent: Sunday, July 29, 2007 7:00:12 PM
Subject: Re: [Tutor] attribute error - quick addition
"Sara Johnson" <sarliz73 at yahoo.com> wrote
> Sorry...I forgot a few more lines at the end of the code. Starts
> with "outfile2write..."
> I also added outfile2.sort()
OK, at leasrt we see where the error occcurs. The problem emains that
you are
trying to sort a file which doesn't have a sort method. You need to
sort the data
before saving it.
Alan G.
================
outfile2=open('missmeas.dat','w')
for key in skeys:
fracmiss=1.*numberMissing(z[key].values())/nsites
outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
if fracmiss>0.:
print outstring
outfile2.write(outstring+'\n') #notice explicit newline \n
outfile2.sort()
outfile2.close()
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
____________________________________________________________________________________
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070730/bb69f11a/attachment.htm
More information about the Tutor
mailing list