Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: datetime string conversion error

Reply
Thread Tools

Re: datetime string conversion error

 
 
Josh English
Guest
Posts: n/a
 
      03-16-2010
On Mar 16, 11:56*am, Jordan Apgar <(E-Mail Removed)> wrote:

> here's what I'm doing:
> date = "2010-03-16 14:46:38.409137"
> *olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f")
>


Due to circumstances, I'm using Python 2.5.4 on one machine (2.6 on
the other).

When I have a script as simple as this:

import datetime

datetime.datetime.strptime('2010-09-14', "%Y-%m-%d")


Running this script brings up a calendar, believe it or not. The
calendar displays March 2010, and shows the 22nd as a holiday. When I
dismiss the dialog box I get:
Traceback (most recent call last):
File "strptimetest.py", line 3, in <module>
datetime.datetime.strptime('2010-09-14', "%Y-%m-%d")
File "C:\Python25\lib\_strptime.py", line 272, in <module>
_TimeRE_cache = TimeRE()
File "C:\Python25\lib\_strptime.py", line 191, in __init__
self.locale_time = LocaleTime()
File "C:\Python25\lib\_strptime.py", line 74, in __init__
self.__calc_weekday()
File "C:\Python25\lib\_strptime.py", line 94, in __calc_weekday
a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
AttributeError: 'module' object has no attribute 'day_abbr'


err... what? Is this an old weirdness I don't remember from the 2.5
series?

I can select dates in the calendar, but nothing dismisses it but the
close box.

Josh English
Incredibly Confused
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-17-2010
En Tue, 16 Mar 2010 20:31:11 -0300, Josh English
<(E-Mail Removed)> escribió:

> On Mar 16, 11:56 am, Jordan Apgar <(E-Mail Removed)> wrote:
>
>> here's what I'm doing:
>> date = "2010-03-16 14:46:38.409137"
>> olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f")
>>

>
> Due to circumstances, I'm using Python 2.5.4 on one machine (2.6 on
> the other).
>
> When I have a script as simple as this:
>
> import datetime
>
> datetime.datetime.strptime('2010-09-14', "%Y-%m-%d")
>
>
> Running this script brings up a calendar, believe it or not. The
> calendar displays March 2010, and shows the 22nd as a holiday. When I
> dismiss the dialog box I get:
> Traceback (most recent call last):
> File "strptimetest.py", line 3, in <module>
> datetime.datetime.strptime('2010-09-14', "%Y-%m-%d")
> File "C:\Python25\lib\_strptime.py", line 272, in <module>
> _TimeRE_cache = TimeRE()
> File "C:\Python25\lib\_strptime.py", line 191, in __init__
> self.locale_time = LocaleTime()
> File "C:\Python25\lib\_strptime.py", line 74, in __init__
> self.__calc_weekday()
> File "C:\Python25\lib\_strptime.py", line 94, in __calc_weekday
> a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
> AttributeError: 'module' object has no attribute 'day_abbr'


I'd say you have a calendar.py script somewhere along your sys.path, that
shadows the calendar module in the standard library.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments