i18n: strftime() with other locale

Martin v. Löwis loewis at informatik.hu-berlin.de
Tue May 14 12:04:19 EDT 2002


Thomas Guettler <zopestoller at thomas-guettler.de> writes:

> time.strftime() depends on the current locale.
> Is there a way to change the locale for just one
> function call?
> 
> It is multithreaded application, and I only want
> to change the local for this call.

That is not supported. You need to protect all of your calls to
strftime with a mutex, and then can change and restore the locale
while you hold the mutex.

Notice that, in a strict sense, you can't make any other use of the
locale while invoking setlocale. However, that *should* work on many C
libraries even though it is not guaranteed.

Regards,
Martin




More information about the Python-list mailing list