Diez B. Roggisch wrote:
W. eWatson wrote:

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?

This is not what you think it is. All your problem is that you do

from datetime import datetime

which imports the datetime-class, but then try to access

datetime.datetime

as if you had done

import datetime.


This actually is a wart in the datetime-module - it would be better if the
classes in there would follow PEP-8.

Diez
That's it. Thanks.

--
                               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: <www.speckledwithstars.net/>

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to