Title: Signature.html
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
        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
        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
    x = time.strptime(fmt_time, "%H %M %S")
with fmt_time = "11 12 40"
in function produces the msg:
Traceback (most recent call last):
  File "C:\Sandia_Meteors\Improved_Sentinel\Sentinel_Playground\Utility_Dev\SU_DateTimeAdjust.py", line 209, in ?
    if not verify_time(bump_time):
  File "C:\Sandia_Meteors\Improved_Sentinel\Sentinel_Playground\Utility_Dev\SU_DateTimeAdjust.py", line 69, in verify_time
    x = time.strptime(fmt_time, "%H %M %S")
AttributeError: 'list' object has no attribute 'strptime'

However, in another function the line
  x = time.strptime(fmt_date, "%m %d %Y")
with fmt_date = "10 02 2008" works just fine.
Does my format string in strptime for time have a problem?

If I use the shell to set fmt_time and x = time.strptime(fmt_time, ..., I have no trouble.

 --

           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

--
Signature.html
           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

Reply via email to