Syntax Problem with strptime in Python 2.4

W. eWatson notvalid2 at
Mon Sep 8 11:51:54 CEST 2008

Apparently, use of strptime of datetime needs a workaround in Python 2.4 to 
work properly. The workaround is d = 
datetime.datetime(*(time.strptime(date_string, format)[0:5])). However, when 
I try to use it, or even use it the regular way, it fails with
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'.
 From the following code code segment:

format = '%Y%m%d_%H%M%S'
#d=datetime.strptime('20080321_113405', format)-- typical use
print time.strptime('20080321_113405', format)[0:5]
d = datetime.datetime(*time.strptime('20080321_113405', format)[0:5])

Does anyone know how to make this work in 2.4? If not, is there a way to 
achieve the same result?
                                W. eWatson

              (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

                     Web Page: <>

More information about the Python-list mailing list