[PyQt] QApplication and datetime.strptime

Michka Popoff michkapopoff at gmail.com
Fri Jun 7 14:23:24 BST 2013


Thanks for your answer.

So it's more a QT thing than PyQt.

I think I'll have to search an alternative to datetime.strptime, which would be compatible with QT/PyQT

Michka

On 5 juin 2013, at 23:19, Phil Thompson <phil at riverbankcomputing.com> wrote:

> On Wed, 5 Jun 2013 22:20:46 +0200, Michka Popoff <michkapopoff at gmail.com>
> wrote:
>> Hi
>> 
>> I am extracting strings containing dates from some files in a pyqt app,
>> and I want to use datetime.strptime to format them.
>> 
>> But this won't work as Qapplication seem to alter my locales. I found
> this
>> topic :
>> 
>> 
> http://stackoverflow.com/questions/14684513/datetime-strptime-doesnt-work-in-pyqt4-qtgui-qwidget-inherited-class
>> 
>> So if I use : os.putenv("LANG", "C"), it will indeed work.
>> 
>> My questions are the following :
>> 
>> - Why does PyQt change the locales ? Is there some documentation on this
> I
>> could read ?
> 
> PyQt does not change the locale. Qt may be another matter.
> 
>> More "pythonic" questions, but related to the problem :
>> - Is it OK to use os.putenv on all platforms ? The python documentation
>> says it is not always provided. (locale.setlocale is platform
> dependent).
>> Setting the value directly in os.environ may causes memory leaks on some
>> platforms.
>> - Are there some specific problems I could have if I use the "C" option
> ?
>> What will be the influence on the pyqt app ?
>> - Is there perhaps a known alternative to datetime.strptime, where I can
>> define the locale temporarily or which works with pyqt ?
>> 
>> Thanks in advance
>> 
>> Michka Popoff
> 
> Phil



More information about the PyQt mailing list