Further info. If I put y = time.strptime("11 01 05", "%H %M %S") both in the function and in the main body. Only the line above in the function produces an error message. Here's a simple program that creates the problem. import datetime def verify_time(in_time): time = in_time.split(":") if len(time) <> 3: print "Invalid format. Try again. hh:mm:ss, hh is 24 hour time." return False y = time.strptime("11 01 05", "%H %M %S") print y, "Yes, y" hour,minute,second = time fmt_time = hour+" "+minute+" "+second print "FMT TIME:", fmt_time x = time.strptime(fmt_time, "%H %M %S") print "fmt time:", fmt_time try: time.strptime(fmt_time, "%H %M %S") nhour = int(hour) nminute = int(minute) nsecond = int(second) except: print "Invalid date values or format (hh:mm:ss): ", in_time print "Valid examples: 15:55:02, 8:20:5" print "Invalid examples: 14: 2:33, 7:11: 4, 11::7" return False return True y = time.strptime("11 01 05", "%H %M %S") atime = "11:12:13" print verify_time(atime) Wayne Watson wrote: The line --
Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet Interesting government experience prior their candidacy: Abraham Lincoln: 2 years; George Washington: 0 years; Dwight Eisenhower: 0 years; James Buchanan: 29 years* Barack Obama: 11 years; John McCain: 26 years * Not a particularly good president at all Web Page: <www.speckledwithstars.net/> |
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor