Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-09 Thread Alan Gauld

"WM."  wrote

Well, Mr. Wilkins takes the biscuit. He found where I did not enter 
a pair of parens.()


But do you understand *why* you got the error and what it was telling 
you?

Pyton's error message told you exactly what you had done wrong
although you may not have quite understood it. But do you now see
what the error message was telling you when it said:

--
  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
--

Can you understand it clearly enough that when a similar error
comes up in future you will know what to look for and where?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/l



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread WM.
Well, Mr. Wilkins takes the biscuit. He found where I did not enter a 
pair of parens.()

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread David

WM. wrote:

I am using Python 26 on a Windows XP

OK, here are the three lines mentioned following the error message.

Traceback (most recent call last):
  File "C:\Python26\TicTacToeD.py", line 165, in 
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


line 165 = main()

def main():
DisplayInstruct()
puter, human = Pieces()
turn = X
board = NewBoard
DisplayBoard(board)

line 150 = DisplayBoard(board)

line 69
def DisplayBoard(board):
"""Display board on screen."""
print "\n\t", board[1], "|", board[2], "|", board[3]
print "\t", "__"
print "\t", board[4], "|", board[5], "|", board[6]
print "\t", "__"
print "\t", board[7], "|", board[8], "|", board[9], "\n"

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



so you have this
def NewBoard():
"""Create new game board."""
board = []
for square in range(NUM_SQUARES):
board.append(EMPTY)
return board

for your DisplayBoard I have this;

def new_board():
"""Create new game board."""
board = []
for square in range(NUM_SQUARES):
board.append(EMPTY)
return board

def display_board(board):
"""Display game board on screen."""
print "\n\t", board[0], "|", board[1], "|", board[2]
print "\t", "-"
print "\t", board[3], "|", board[4], "|", board[5]
print "\t", "-"
print "\t", board[6], "|", board[7], "|", board[8], "\n"



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

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread Brett Wilkins

Your problem:


def main():
   DisplayInstruct()
   puter, human = Pieces()
   turn = X
   board = NewBoard<<<--This line
   DisplayBoard(board)

if you read my email before, I described this to you :) put brackets on 
the end of NewBoard (so NewBoard() ) and this should work.

Cheers

WM. wrote:

I am using Python 26 on a Windows XP

OK, here are the three lines mentioned following the error message.

Traceback (most recent call last):
  File "C:\Python26\TicTacToeD.py", line 165, in 
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


line 165 = main()

def main():
DisplayInstruct()
puter, human = Pieces()
turn = X
board = NewBoard
DisplayBoard(board)

line 150 = DisplayBoard(board)

line 69
def DisplayBoard(board):
"""Display board on screen."""
print "\n\t", board[1], "|", board[2], "|", board[3]
print "\t", "__"
print "\t", board[4], "|", board[5], "|", board[6]
print "\t", "__"
print "\t", board[7], "|", board[8], "|", board[9], "\n"



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread WM.

I am using Python 26 on a Windows XP

OK, here are the three lines mentioned following the error message.

Traceback (most recent call last):
  File "C:\Python26\TicTacToeD.py", line 165, in 
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


line 165 = main()

def main():
DisplayInstruct()
puter, human = Pieces()
turn = X
board = NewBoard
DisplayBoard(board)

line 150 = DisplayBoard(board)

line 69
def DisplayBoard(board):
"""Display board on screen."""
print "\n\t", board[1], "|", board[2], "|", board[3]
print "\t", "__"
print "\t", board[4], "|", board[5], "|", board[6]
print "\t", "__"
print "\t", board[7], "|", board[8], "|", board[9], "\n"

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread David

bob gailer wrote:

Kapsicum wrote:



On Mon, Mar 9, 2009 at 1:18 AM, WM. > wrote:


Traceback (most recent call last):
 File "C:\Python26\TicTacToeD.py", line 165, in 
   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

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread Brett Wilkins

Found this book at the local library...

If you're doing the TicTacToe game in chapter 6, then have a look at the 
main function (def main: ) and find the line that says

   board = new_board()

This is likely where your troubles lie...

Cheers
--Brett

John Fouhy wrote:

2009/3/9 WM. :
  

Thank you for your remarks. Too bad they fell into my acres of ignorance.
One thing is certain, Dawson used brackets [] not parens (). When I spoke of
typi (plural of typo) I meant ; for : or \ for /, not line after line of
error.
My only alternative now seems to be 'get out the old curry comb' and go
letter by letter, between the monitor and the page. Headache time.



I think Brett's suggestion is the most likely one.  Look for a line
that starts with:

board =

That's probably where your error is.

  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread John Fouhy
2009/3/9 WM. :
> Thank you for your remarks. Too bad they fell into my acres of ignorance.
> One thing is certain, Dawson used brackets [] not parens (). When I spoke of
> typi (plural of typo) I meant ; for : or \ for /, not line after line of
> error.
> My only alternative now seems to be 'get out the old curry comb' and go
> letter by letter, between the monitor and the page. Headache time.

I think Brett's suggestion is the most likely one.  Look for a line
that starts with:

board =

That's probably where your error is.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread WM.

Brett Wilkins wrote:
Given that board is a function then I believe that it is likely you're 
either (a) doing something wrong beforehand, or (b) if board is a 
function that generates the Tic Tac Toe board, then the syntax you more 
likely need is board()[number] , but I can't be completely certain.


when I say doing something wrong beforehand, I'm thinking you might be 
accidentally giving the funtion a new name, instead of  assigning it's 
return value to a variable,

like so:

newname = functionname   //see here, no brackets on the end of the 
function, this basically tells python that newname is also functionname.
variable = functionReturningValue()   //and here, the function's return 
value is obviously being assigned to the variable


Disclaimer: My naming scheme sucks, I know this :)

Cheers
--Brett

John Fouhy wrote:

2009/3/9 WM. :
 

 File "C:\Python26\TicTacToeD.py", line 68, in DisplayBoard
   print "\n\t", board[1], "|", board[2], "|", board[3]
TypeError: 'function' object is unsubscriptable

I am fooling around with Dawson's "...for the Absolute Beginner". The
tic-tac-toe program will not run for me. I'm guessing a typi 
somewhere, but

cannot find it.



"subscript" means "a thing in square brackets after a name".  You've
got three subscripts in that line: board[1], board[2], and board[3].

The error means that you're trying to use square brackets after
something that doesn't support them.  It's telling you that 'board' is
a function (as opposed to a list or a dict, for example) and functions
don't support [].

Possibly you're meant to call board:

print "\n\t", board(1), "|", board(2), "|", board(3)

Or, alternatively, you may have assigned to it by mistake somewhere.

  




Thank you for your remarks. Too bad they fell into my acres of ignorance.
One thing is certain, Dawson used brackets [] not parens (). When I 
spoke of typi (plural of typo) I meant ; for : or \ for /, not line 
after line of error.
My only alternative now seems to be 'get out the old curry comb' and go 
letter by letter, between the monitor and the page. Headache time.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread bob gailer

Kapsicum wrote:



On Mon, Mar 9, 2009 at 1:18 AM, WM. > wrote:


Traceback (most recent call last):
 File "C:\Python26\TicTacToeD.py", line 165, in 
   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__

--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread Brett Wilkins
Given that board is a function then I believe that it is likely you're 
either (a) doing something wrong beforehand, or (b) if board is a 
function that generates the Tic Tac Toe board, then the syntax you more 
likely need is board()[number] , but I can't be completely certain.


when I say doing something wrong beforehand, I'm thinking you might be 
accidentally giving the funtion a new name, instead of  assigning it's 
return value to a variable,

like so:

newname = functionname   //see here, no brackets on the end of the 
function, this basically tells python that newname is also functionname.
variable = functionReturningValue()   //and here, the function's return 
value is obviously being assigned to the variable


Disclaimer: My naming scheme sucks, I know this :)

Cheers
--Brett

John Fouhy wrote:

2009/3/9 WM. :
  

 File "C:\Python26\TicTacToeD.py", line 68, in DisplayBoard
   print "\n\t", board[1], "|", board[2], "|", board[3]
TypeError: 'function' object is unsubscriptable

I am fooling around with Dawson's "...for the Absolute Beginner". The
tic-tac-toe program will not run for me. I'm guessing a typi somewhere, but
cannot find it.



"subscript" means "a thing in square brackets after a name".  You've
got three subscripts in that line: board[1], board[2], and board[3].

The error means that you're trying to use square brackets after
something that doesn't support them.  It's telling you that 'board' is
a function (as opposed to a list or a dict, for example) and functions
don't support [].

Possibly you're meant to call board:

print "\n\t", board(1), "|", board(2), "|", board(3)

Or, alternatively, you may have assigned to it by mistake somewhere.

  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread John Fouhy
2009/3/9 WM. :
>  File "C:\Python26\TicTacToeD.py", line 68, in DisplayBoard
>    print "\n\t", board[1], "|", board[2], "|", board[3]
> TypeError: 'function' object is unsubscriptable
>
> I am fooling around with Dawson's "...for the Absolute Beginner". The
> tic-tac-toe program will not run for me. I'm guessing a typi somewhere, but
> cannot find it.

"subscript" means "a thing in square brackets after a name".  You've
got three subscripts in that line: board[1], board[2], and board[3].

The error means that you're trying to use square brackets after
something that doesn't support them.  It's telling you that 'board' is
a function (as opposed to a list or a dict, for example) and functions
don't support [].

Possibly you're meant to call board:

print "\n\t", board(1), "|", board(2), "|", board(3)

Or, alternatively, you may have assigned to it by mistake somewhere.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread Kapsicum
On Mon, Mar 9, 2009 at 1:18 AM, WM.  wrote:

> Traceback (most recent call last):
>  File "C:\Python26\TicTacToeD.py", line 165, in 
>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


>
>
> I am fooling around with Dawson's "...for the Absolute Beginner". The
> tic-tac-toe program will not run for me. I'm guessing a typi somewhere, but
> cannot find it.
>
> My questions here are;
> can somebody tell me, in a general way, what the error message means?
> is there, somewhere, a list of error messages with explanations?
> is there, somewhere, a dictionary of Python words, such as
> 'unsubscriptable'?






>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Kapil Dua
Mobile: +919711311052
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread WM.

Traceback (most recent call last):
  File "C:\Python26\TicTacToeD.py", line 165, in 
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

I am fooling around with Dawson's "...for the Absolute Beginner". The 
tic-tac-toe program will not run for me. I'm guessing a typi somewhere, 
but cannot find it.


My questions here are;
can somebody tell me, in a general way, what the error message means?
is there, somewhere, a list of error messages with explanations?
is there, somewhere, a dictionary of Python words, such as 
'unsubscriptable'?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor