I've heard about using assert() to check up on whether things are still working correctly, or something like that. So I've begun to write some assert() expressions(?) and put them at the bottom of the module.
if __name__ == '__main__':
OUTPUT:
For primes up through 101, max diff is 8
between the 1 pair(s) of primes [(89, 97)]
Time was 12.99 seconds
Time was 15 minutes, 35 seconds
Time was 2 hours, 47 minutes, 6 seconds
The top three work silently, but I found that I could not figure out how to use assert() with the functions that print rather than return. E.g., maxDiffBetPrimes() and printTime(). Is there a way?
If it'll help, here's printTime():
def printTime(timeEnd, timeStart):
from mycalc import hmsToText
timeElapsed = timeEnd - timeStart
if timeElapsed > 60:
print "Time was", hmsToText(timeElapsed)
else:
print "Time was %.4g seconds" % timeElapsed
Thanks,
Dick Moores
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
