[Tutor] IDLE Crashing
Luke Paireepinart
rabidpoobear at gmail.com
Sat Aug 5 08:52:51 CEST 2006
Hi Adam.
Adam Gomaa wrote:
> I'm having trouble with this script. When I run it, it crashes IDLE...
> which is no fun. :(
>
> I'm running Ubuntu 6.06 w/ python 2.4
>
> When I say crash, I mean really _crash_. IDLE stop responding, and I
> have to killall idle && killall python2.4 before I can restart it (cause
> python2.4 keeps the TCP port open, I'm assuming)
>
> A few notes:
> list.txt is a text file with 99 lines, each with three letters on it.
> In ./retrieves, I have 99 files of style [xyz].1.txt. (in addition to
> list.txt) These are retrieved HTML pages that have the HTML stripped
> (the actual script is part of a series of scripts to download and format
> my school's course catalog)
> It seems to crash on the final iteration of the second for loop, no
> matter what file it's on at that point (which I've changed by changing
> x&y in 'for each in filelist[x:y]:' to diffrent values), so I don't
> think it has anything to do with the actual files it's accessing.
>
> -----
> #2006 Adam Gomaa, Public Domain
> listfiles=open('retrieves/list.txt','r')
> fileread=listfiles.read() ##reads list.txt and assings to fileread
> filelist=[]
> filelist=fileread.splitlines() ##each filelist word is 3-letter combo
> listfiles.close()
> count,count2=0,0 ##for debugging
> textstringlist=[]
> goodlist1=[]
> for each in filelist[:-50]: ##filelist[x:y] always crashes for any value
> of x,y
> print count ##for debugging
> count=count+1
> textfileread=open('retrieves/%s.1.txt' % each,'r')
> textstring=textfileread.read()
> textfileread.close()
> each=each.upper()
> textstringlist=textstring.split(each)##if I comment out from here...
>
Did you really mean to split the string on every occurrence of 'each'
and not on each newline?
> for each2 in textstringlist[:]: #changing to textstringlist[3:-3]
> still results in crash
> count2=count2+1
> print count2,'is count2' ##this gets quite high, into thousands,
> before stopping on the final iteration (and crashing)
> if 'Prerequisites' in each2:
> goodlist1.append(each2)##to here, it doesn't crash
> print goodlist1
> ------
>
> Anyone have an insight?
> If someone would like me to I can tar the 99 files & list.txt and post a
> link.
>
I can't tell what's wrong without looking at your input files and a more
detailed explanation of what
you're trying to do. If someone else comes along with help, that's
great, but if not, I'll download the
tar and see what I can do.
> Thanks,
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list