----- Original Message -----
> From: eryksun <[email protected]>
> To: Albert-Jan Roskam <[email protected]>
> Cc: Python Mailing List <[email protected]>
> Sent: Wednesday, February 20, 2013 1:37 PM
> Subject: Re: [Tutor] locale.set/getlocale asymmetry
> 
> On Wed, Feb 20, 2013 at 5:53 AM, Albert-Jan Roskam <[email protected]> 
> wrote:
>> There is an asymmetry in getlocale and setlocale. What is returned by
>> getlocale cannot be used as argument for setlocale.
> 
> getlocale executes localename = _setlocale(category), where _setlocale
> wraps the C runtime setlocale. Then it transforms the return string to
> a tuple using _parse_localename, which calls locale.normalize. The
> latter changes the language and encoding incorrectly on Windows.
> Instead, you could save the unparsed locale string: old_locale =
> setlocale(LC_ALL).

Hi Eryksun,

Thank you. So can I simply use the function below to replace locale.getlocale()?
Will this never cause problems? The thing I remember about setlocale is that 
"thou shalt never call setlocale anywhere else but in the beginning of a 
script".
Or am I wrong here? I am always a little reluctant to mess with the host locale.
 
def getlocale(category=locale.LC_ALL):
    return locale.setlocale(category)
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to