[Tutor] Looking for suggestions for improving chessTimer.py code

Dick Moores rdm at rcblue.com
Fri Oct 26 11:18:08 CEST 2007

At 09:33 AM 10/25/2007, Dick Moores wrote:
>Please give me constructive criticism of

Hmm. Nothing. One problem may be that only people using Windows can 
run the script.

I've developed chessTimer a bit further: 

I'm still hoping for some constructive criticism. But I also thought 
I'd mention the points I have doubts about:
1. Is wrapping the long lines where I have done so OK?
2. I've used 1 for White player, -1 for Black player, and (-1)*player 
to alternate players. Is there a better way?
3. I've used a lot of variables. Too Many?
4. Should more of the code be in functions?
5. Is there a way to collapse lines 107-114:
if player == 1: # player is White
                 whiteMoveCounter += 1
                 print "Black to make move %d" % (blackMoveCounter)
                 remainingWhiteTime -= timeUsedThisMove
elif player == -1: # player is Black
                 blackMoveCounter += 1
                 print "White to make move %d" % (whiteMoveCounter)
                 remainingBlackTime -= timeUsedThisMove


Dick Moores

More information about the Tutor mailing list