[wxPython-users] OT - strptime problems

Werner F. Bruhin werner.bruhin at free.fr
Tue Feb 5 05:11:02 PST 2008


Hi Robin,

Robin Dunn wrote:
> Werner F. Bruhin wrote:
>> Sorry for being a bit OT.
>>
>> I am in the midst of converting over to the Unicode build and I am 
>> running into a problem with my custom column sorter for dates
>>
>> I wonder if anyone can give me a hint why this would not work:
>>
>> x
>> u'16 ao\xfbt 2005'
>>  >>> tempformat
>> u'%d %b %Y'
>>  >>> time.strptime(x, tempformat)
>>  File "<console>", line 1, in <module>
>>  File "C:\Python25\lib\_strptime.py", line 331, in strptime
>>    (data_string, format))
>> ''' <type 'exceptions.ValueError'> : time data did not match format:  
>> data=16 août 2005  fmt=%d %b %Y '''
>>  >>> print x
>> 16 août 2005
>>
>> I tried converting things to string but I still get the same error.  
>> It is strange in my app I actually get a decode error when I run the 
>> equivalent code - so I am totally confused.
>
> Does it make any difference if you use strings instead of Unicode 
> objects for the date and format?  (Probably need to be encoded to 
> whatever is the default system encoding for your locale.)
Tried that but doesn't make any difference.

For the moment I just work around this by using %d %m %Y instead, no 
problem with this.

Thanks for the hint
Werner





More information about the wxpython-users mailing list