Greetings, On 10/26/07, Dick Moores <[EMAIL PROTECTED]> wrote: > At 09:33 AM 10/25/2007, Dick Moores wrote: > >Please give me constructive criticism of > ><http://www.rcblue.com/Python/chessTimerForWebV6.py> > > Hmm. Nothing. One problem may be that only people using Windows can > run the script.
The first thing I saw when I looked at the code was that it was for MS-Windows only, so I didn't waste anymore time with it. Recently, I ran across some code that tried MS-Windows, except if the user wasn't running MS-Windows, it assumed they were running some *nix variant, and loaded those modules instead. That certainly makes code more platform independent. This is what it looked like: try: # windows or dos import msvcrt getkey = msvcrt.getch except ImportError: # assume unix import tty, termios Since Python doesn't come bundled with MS-Windows, out-of-the-box, I don't think we should presume that "everyone" has Python on their MS-Windows computer? OTOH, Python is usually part of the base or core system on a GNU/Linux install. I'm not sure about Mac OS X.x? Of course, if you only want MS-Windows users to run your code, then.... nevermind! 8^D I'm still working my way through Python tutorials, and as yet, haven't written any code that makes use of any platform specific libraries. However, when I DO, and IF I forget to try:except: so other platforms can run my code, Please Slap Me, and show me THIS post! =) That being said: Besides msvcrt/curses, what other libraries are there that we should be aware of? I'd like to see them as pairs, if possible.... this looks like a perfect thing for a dictionary! =) I certainly think this is something that Newbies (like myself) should learn. But without a MS-Windows computer handy, I don't know? Is there a place that has this information? Happy Programming! -- b h a a l u u at g m a i l dot c o m http://www.geocities.com/ek.bhaaluu/index.html > > I've developed chessTimer a bit further: > <http://www.rcblue.com/Python/chessTimerFischerDelayForWebV2.py> > > 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 > > > Thanks, > > Dick Moores > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor