Title: Signature.html
Well, maybe. Here's the file the change and results:
# Using datetime to do date-time math on a file date-time stamp and
# the creating the new stamp
from datetime import datetime, timedelta

format = '%Y%m%d_%H%M%S'
#d=datetime.strptime('20080321_113405', format)
d = datetime.datetime(*(time.strptime('20080321_113405', format)[0:6]))
print d
datetime.datetime(2008, 3, 21, 11, 34, 5)
d += timedelta(seconds=200)
print d
datetime.datetime(2008, 3, 21, 11, 37, 25)
print d.strftime(format
Results:
Traceback (most recent call last):
  File "C:/Sandia_Meteors/Improved_Sentinel/Sentinel_Playground/Utility_Dev/debugDateTime.py", line 7, in ?
    d = datetime.datetime(*(time.strptime('20080321_113405', format)[0:6]))
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'

>From a PLEAC web:
# The easiest way to convert this to a datetime seems to be; 
now = datetime.datetime(*time.strptime("16/6/1981", "%d/%m/%Y")[0:5])
# the '*' operator unpacks the tuple, producing the argument list.
I tried the [0:6] and it got the same results.

John Fouhy wrote:
2008/9/8 Wayne Watson <[EMAIL PROTECTED]>:
  
I'm sure you have the essence below, but I'm not familiar with the In/ Out
notation. Apparently, I need to scoop up the In lines into a file and add
some print stmts for the In[x] d lines.
    

Kent uses IPython, which is an enhanced version of the standard python
shell.  That's what the In[] and Out[] bits are from.

  
AttributeError: type object 'datetime.datetime' has no attribute 'strptime

This attribute problem is reminiscent of my problems. IDLE? Python 2.4.x?
    

Python 2.4, unfortunately.  datetime.strptime only came in with Python
2.5, IIRC.  The Python 2.4 version is:

d = datetime.datetime(*(time.strptime(date_string, format)[0:6]))

(i.e. that corresponds to "d = datetime.datetime.strptime(date_string, format)")

  

--
           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
            
          "If voting made any difference they wouldn't let us do it." 
                        -- Mark Twain
            
                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to