Nitpicking - slightly misleading traceback

Juho Schultz juho.schultz at helsinki.fi
Thu Jan 26 08:37:41 EST 2006


if ((data[x][y] > 0) or
     (datadict.has_key[key])):

Traceback (most recent call last):
   File "reduce.py", line 524, in remove_badvalues
     if ((data[x][y] > 0) or
TypeError: unsubscriptable object

However, the bug sits on the next line. I used square brackets when 
normal brackets were needed - should have written datadict.has_key(key) 
as the old code had datadict[key]. In the real code variable names are 
so long that I must split the line. I feel the traceback is misleading.

I guess the best solution is to write code without bugs...



More information about the Python-list mailing list