Kevin M wrote: > Figures. I'll try to complicate it sufficiently ;) > > > [edit] I was going to try to sum up what goes on, but I realized that I > was retyping what I already programmed in an effort to better > illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's > only around 200 lines total. > > Class file -- http://pastebin.4programmers.net/640
Any *good* reason you have (a) split your solution in an arbitrary fashion [some in a class, some not] (b) put the class in a separate file? > Main file -- http://pastebin.4programmers.net/639 > > PLEASE don't worry about any file parsing stuff. That's all working > well. The problem is that I'm getting IndexError exceptions in my > _a_count and _b_count methods when they're called from analyze(). I > added some code to increase verbosity, and it turns that the count > methods within the Test class are operating on EMPTY lists ( [] ), so > naturally they can't index anything. This is the core of the problem, > especially considering that line 98 in main.py works as expected. > Line 98 is # print arrTests[2].data This doesn't show that *all* cases have non-empty lists. Data is appended *conditionally* around about line 92. <aside> The try/except adds another level of (totally unnecessary, AFAICT) complexity & stuffupability -- you should really do it the other way around: for line in arrLines: row = line.split()[offset:] for index, test in enumerate(arrTests): blah = row[index] if blah not in bad_vals: etc and *don't* ignore IndexError (with this rearrangement, any IndexError is a bug). </aside> To demonstrate that you have a real problem: (1) replace line 98 by: print [i, len(x.data), id(x) for i, x in enumerate(arrTests)] (2) after line 26 in your class file, insert print id(self), len(self.data) [The id() will tell you unequivocably which test object has the problem when/if the _a_sort method fails] HTH, John P.S. Next time, show your actual output. -- http://mail.python.org/mailman/listinfo/python-list