
February 12th, 2012, 01:56 PM
|
 |
Contributing User
|
|
|
|
Before we discover how to clone your object:
You have a couple functions like shown. That is, the __doc__ claims the function will raise some exception if conditions warrant. It's true that these functions do what they say, BUT they also trap the exception within the same function, and the function ends up returning None. Is that your intent?
Code:
def is_valid_move(self, move):
"""Check if a proposed move is valid.
A valid move is a move to a location that does not already
contain either an 'X' or an 'O'.
The parameter move must be an integer between (and including)
move.MIN_MOVE and move.MAX_MOVE, or a MoveValueError exception
will be raised.
"""
try:
if move > move.MAX_MOVE or move < move.MIN_MOVE:
raise MoveValueError
else:
return self._board[move - 1] not in 'XO'
except:
pass
|