Re: datetime string conversion error

Discussion in 'Python' started by Josh English, Mar 16, 2010.

  1. Josh English

    Josh English Guest

    On Mar 16, 11:56 am, Jordan Apgar <> 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.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
    Josh English, Mar 16, 2010
    #1
    1. Advertising

  2. En Tue, 16 Mar 2010 20:31:11 -0300, Josh English
    <> escribió:

    > On Mar 16, 11:56 am, Jordan Apgar <> 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.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
    Gabriel Genellina, Mar 17, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    691
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    524
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    379
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    330
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    745
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page