what the heck does this mean?

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Dec 13 05:28:22 EST 2007


(Answering to Katie Smith)
> katie smith wrote:
>> Traceback (most recent call last):
>>   File "C:\Python25\empire\Empire Strategy.pyw", line 322
>>     Maty = Searched(number)
>> TypeError: 'list' object is not callable

And which is line 322 ?

>> My list is NewMap1 =[0,0,0,0,0,0,2,0,2,2,3,2,0,0,0,0]
>>  
>> so Maty Searched(number is supposed to give me 0 when
>>         Search = "NewMap"
>>         number = 0
>>         bignum = 1
>>         bignumer = repr(bignum)
>>         Searching = Search+bignumer
>>         Searched = eval(Searching)
>>         Maty = Searched[number]

Out of context, this really looks like a major WTF to me. Whenever you 
see 'eval' in your code, you can suspect a serious conception problem. 
You may want to read the doc, specially about getattr(), locals() and 
globals(). Or simply learn how to pass params... to functions.

>> instead i get that error whats up? i thought it is suppose to give me
>> NewMap1(0).

If NewMap1 is a list, trying to apply the call operator to it will 
indeed raise a TypeError with a message similar to the one you posted. 
Hint: in Python, parens are the function call operator. If you want 
subscripting, use brackets (ie : "some_list[index]", not 
"some_list(index)". Here again, reading the FineManual would be a good 
idea, because this is really Python 101.

>>when I print it it works fine  and gives me the result 0
>> but when I go to save the number as Maty-(randomletters) it keeps
>> giving me the stupid error.

The "stupid error" is usually indicating a problem in the code. Now 
since I don't see any readable code here, I just can't help. If you hope 
help, please post minimal working code[1] reproducing your problem. 
FWIW, chances are you'll spot the problem in the way...

[1] meaning: anyone can copy/paste the code snippet and run it.



More information about the Python-list mailing list