[Tutor] UNSUBSCRIPTABLE?

David david at abbottdavid.com
Mon Mar 9 02:19:20 CET 2009


bob gailer wrote:
> Kapsicum wrote:
>>
>>
>> On Mon, Mar 9, 2009 at 1:18 AM, WM. <wferguson1 at socal.rr.com 
>> <mailto:wferguson1 at socal.rr.com>> wrote:
>>
>>     Traceback (most recent call last):
>>      File "C:\Python26\TicTacToeD.py", line 165, in <module>
>>        main()
>>      File "C:\Python26\TicTacToeD.py", line 150, in main
>>        DisplayBoard(board)
>>      File "C:\Python26\TicTacToeD.py", line 68, in DisplayBoard
>>        print "\n\t", board[1], "|", board[2], "|", board[3]
>>     TypeError: 'function' object is unsubscriptable
>>
>>  
>> error means the object returned is not of type sequence
> 
> No. It means that the object does not have a way to handle []. Many 
> objects are subscriptable besides sequences.
> 
> dict, set, objects with certain "special methods" e.g., __getitem__
> 
how about;
print "\n\t", board[0], "|", board[1], "|", board[2]

-- 
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu



More information about the Tutor mailing list