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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to