[Tutor] attribute error - quick addition

Sara Johnson sarliz73 at yahoo.com
Mon Jul 30 23:56:32 CEST 2007

Sorry...  I'm still learning about lists, tuples, etc...


----- Original Message ----
From: Tiger12506 <keridee at jayco.net>
To: tutor at python.org
Sent: Monday, July 30, 2007 5:42:47 PM
Subject: Re: [Tutor] attribute error - quick addition

> Thanks Alan and Kent (for the sorting notes)!
> Alan...I guess I thought outfile2 had data.  { i.e., 
> outfile2=open('missmeas.dat','w') }

Argghh!!! No, no, no! Attribute Error! No matter how much data you have in 
the file, you will *never* be able to call sort on it, because file objects 
do not understand sort. They do not have the "attribute" called "sort". 
Lists have sort. If you want to sort them like you are trying, you will have 
to convert the file into a list (of lines).

lst = list(outfile2)


> My mistake.
> Thanks,
> Sara

Tutor maillist  -  Tutor at python.org

Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070730/d73b9461/attachment.htm 

More information about the Tutor mailing list