[Tutor] Looking to improve my stopWatch.py

bob gailer bgailer at alum.rpi.edu
Wed Oct 24 23:14:51 CEST 2007


Dick Moores wrote:
> Please give me constructive criticism of 
> <http://www.rcblue.com/Python/stopWatchForWeb14-a.py>
>   
1 - lapCounter is not used.

2 - simplify:

                if lapTimeFlag == False:
                    print "Total Time is", secsToHMS(totalTime)
                    print "StopWatch is continuing to time.."
                else:
                    currentLapTime = markTime - lapEnd
                    print "Current time of this lap, Lap %d, is %s" % (lapNum, secsToHMS(currentLapTime))
                    print "Total Time is", secsToHMS(totalTime)
                    print "StopWatch is continuing to time.."

    new version:

                if lapTimeFlag:
                    currentLapTime = markTime - lapEnd
                    print "Current time of this lap, Lap %d, is %s" % (lapNum, secsToHMS(currentLapTime))
                print "Total Time is", secsToHMS(totalTime)
                print "StopWatch is continuing to time.."





More information about the Tutor mailing list