Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

programmatically change windows regional settings?

203 views
Skip to first unread message

Albert-Jan Roskam

unread,
May 24, 2015, 8:52:51 AM5/24/15
to pytho...@python.org

Hi,

In Windows I can change the regional settings manually in the control panel. But how do I do this programmatically? I tried setting LANG but this does not work in Windows.

Kernel32's SetLocaleInfo sounds promising, but "This setting only affects the user override portion of the locale settings; it does not set the system defaults." https://msdn.microsoft.com/en-us/library/ee491893(v=winembedded.60).aspx

Another route might be _winreg (but that's probably more brittle and, more importantly, the registry sucks)

My goal is to easily run my unittests in a number of locales (actually a platform x locale x python version matrix)

Thanks!

Albert-Jan

Mark Lawrence

unread,
May 24, 2015, 9:08:14 AM5/24/15
to pytho...@python.org
You're probably better off asking this on
https://mail.python.org/mailman/listinfo/python-win32 which is also
available as gmane.comp.python.windows, although you might get lucky
here. If you do a rather more specific statement than "this does not
work in Windows" would be helpful. Your Python and Windows version(s)
might possibly assist as well :)

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Albert-Jan Roskam

unread,
May 24, 2015, 10:16:41 AM5/24/15
to bream...@yahoo.co.uk, pytho...@python.org

-----------------------------
On Sun, May 24, 2015 3:07 PM CEST Mark Lawrence wrote:

>On 24/05/2015 13:50, Albert-Jan Roskam via Python-list wrote:
>>
>> Hi,
>>
>> In Windows I can change the regional settings manually in the control panel. But how do I do this programmatically? I tried setting LANG but this does not work in Windows.
>>
>> Kernel32's SetLocaleInfo sounds promising, but "This setting only affects the user override portion of the locale settings; it does not set the system defaults." https://msdn.microsoft.com/en-us/library/ee491893(v=winembedded.60).aspx
>>
>> Another route might be _winreg (but that's probably more brittle and, more importantly, the registry sucks)
>>
>> My goal is to easily run my unittests in a number of locales (actually a platform x locale x python version matrix)
>>
>> Thanks!
>>
>> Albert-Jan
>>
>
>You're probably better off asking this on
>https://mail.python.org/mailman/listinfo/python-win32 which is also
>available as gmane.comp.python.windows, although you might get lucky
>here.

Ok, I'll check that out, thanks. Hope that list is about more than win32com

If you do a rather more specific statement than "this does not
>work in Windows" would be helpful.

One can set LANG in Windows (of course), but Windows does not appear to ever use it. So it's pointless.
setx LANG France.French.1252 && python -c "from locale import *; setlocale(LC_ALL, ''); print(getlocale())"

... Does not print a French locale on my non-French system

>Your Python and Windows version(s)
>might possibly assist as well :)


Windows Server 2012 R2 (x64), and preferably also Win 7 x64. Python 2.7, 3.3, 3.4, and ideally also pypy.


>--
>My fellow Pythonistas, ask not what our language can do for you, ask
>what you can do for our language.
>
>Mark Lawrence
>
>--
>https://mail.python.org/mailman/listinfo/python-list

Laura Creighton

unread,
May 24, 2015, 10:46:06 AM5/24/15
to Mark Lawrence, pytho...@python.org, l...@openend.se
In a message of Sun, 24 May 2015 14:07:37 +0100, Mark Lawrence writes:
>On 24/05/2015 13:50, Albert-Jan Roskam via Python-list wrote:
>>
>> Hi,
>>
>> In Windows I can change the regional settings manually in the control panel. But how do I do this programmatically? I tried setting LANG but this does not work in Windows.
>>
>> Kernel32's SetLocaleInfo sounds promising, but "This setting only affects the user override portion of the locale settings; it does not set the system defaults." https://msdn.microsoft.com/en-us/library/ee491893(v=winembedded.60).aspx
>>
>> Another route might be _winreg (but that's probably more brittle and, more importantly, the registry sucks)
>>
>> My goal is to easily run my unittests in a number of locales (actually a platform x locale x python version matrix)
>>
>> Thanks!
>>
>> Albert-Jan

>You're probably better off asking this on
>https://mail.python.org/mailman/listinfo/python-win32 which is also
>available as gmane.comp.python.windows, although you might get lucky
>here. If you do a rather more specific statement than "this does not
>work in Windows" would be helpful. Your Python and Windows version(s)
>might possibly assist as well :)
>
>--
>My fellow Pythonistas, ask not what our language can do for you, ask
>what you can do for our language.
>
>Mark Lawrence

I actually think he will get the best advice from the testing-in-python
mailing list.

http://lists.idyll.org/listinfo/testing-in-python

Laura

Albert-Jan Roskam

unread,
May 24, 2015, 11:07:45 AM5/24/15
to l...@openend.se, bream...@yahoo.co.uk, pytho...@python.org

-----------------------------
:-) That's indeed what I've done initially, but my message does not get posted. But maybe that list is moderated and I'm too impatient. But TIP is indeed the place to be for Tox-related questions.

Mark Lawrence

unread,
May 24, 2015, 11:23:41 AM5/24/15
to pytho...@python.org
On 24/05/2015 15:16, Albert-Jan Roskam via Python-list wrote:
>
> -----------------------------
> On Sun, May 24, 2015 3:07 PM CEST Mark Lawrence wrote:
>>
>> You're probably better off asking this on
>> https://mail.python.org/mailman/listinfo/python-win32 which is also
>> available as gmane.comp.python.windows, although you might get lucky
>> here.
>
> Ok, I'll check that out, thanks. Hope that list is about more than win32com
>

From the above link "All issues related to programming Python on
Windows. win32 extensions, COM, you name it."

Laura Creighton

unread,
Jun 1, 2015, 7:00:31 AM6/1/15
to Mark Lawrence, pytho...@python.org, l...@openend.se
In a message of Mon, 01 Jun 2015 11:34:08 +0100, Mark Lawrence writes:

>In the wonderful world of numbers I believe that things are looking up.
> I don't recall a new issue on the bug tracker for several months along
>the lines of "Python can't do arithmetic properly".

How Great to Hear! <cheer cheer cheer>

But I wonder how much of that has to do with changing division?

OpenEnd (my company) makes bookkeeping systems for Swedish Ideal
Societies (closest English words 'non-profits' and 'clubs'). A
surprising number of our potential customers are relying on code
written more than 20 years ago, by somebody who is no longer part of
the Society which used floats for arithmetic. Hard to make the sale
when the customer thinks your math is broken. So I am biased, but in
my little corner of the world, Float Confusion Reigns Supreme.

Laura

Laura Creighton

unread,
Jun 18, 2015, 7:02:14 PM6/18/15
to Mark Lawrence, pytho...@python.org, l...@openend.se
In a message of Thu, 18 Jun 2015 11:50:28 +0100, Mark Lawrence writes:
>Throw in http://clonedigger.sourceforge.net/ as well and you've a really
>awesome combination.
>
>Mark Lawrence
>

I didn't know about that one.
Hey thank you, Mark. Looks great.

It needs its own entry in
https://wiki.python.org/moin/PythonTestingToolsTaxonomy

You add it, or me?

Laura

Mark Lawrence

unread,
Jun 20, 2015, 6:52:47 PM6/20/15
to pytho...@python.org
Thanks all the same but I'll leave it to you, as I suspect I'd be my
usual combination of headless chicken and bull in a china shop if let
loose on a wiki :)

Laura Creighton

unread,
Jun 21, 2015, 4:27:10 AM6/21/15
to Mark Lawrence, pytho...@python.org
Ah, turns out there was an entry. I updated it.

Laura

Laura Creighton

unread,
Jun 25, 2015, 8:48:29 AM6/25/15
to Mark Lawrence, pytho...@python.org, l...@openend.se
In a message of Thu, 25 Jun 2015 11:58:09 +0100, Mark Lawrence writes:
>On 24/06/2015 16:56, Knss Teja via Python-list wrote:
>> I WANT TO install 4.3 version ... but the MSI file is giving a DLL error
>> .. what should I do :/
>> please use REPLY ALL .. so that I get the mail to my gmail inbox
>>
>
>I'll assume that you mean 3.4.x. Please give the x, your Windows
>version and the precise error message that you're getting, then we
>should be able to help.
>
>--
>My fellow Pythonistas, ask not what our language can do for you, ask
>what you can do for our language.
>
>Mark Lawrence

Note that some people I know of, via webmaster, found that they
could install 3.4.x with the ActiveState installer but not the python.org
one. Apparantly ActiveState bundles up some DLLs in its installer
'in case the user doesn't have them' whereas we don't -- and turns out
some users don't have them. I have never been able to get enough out
of a user to find out exactly what magic sauce they have that we do
not -- it would be really nice to find out so that we can add it too.

No guarantees that this particular user has this particular problem,
of course.

Laura

Laura Creighton

unread,
Jul 12, 2015, 4:30:05 PM7/12/15
to Mark Lawrence, pytho...@python.org, l...@openend.se
In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes:
>On 12/07/2015 20:47, Laura Creighton wrote:
>> Simon Evans -- what editor are you using to write your Python code with?
>>
>> Laura Creighton
>>
>
>Editor? His earlier posts clearly show he's using the 2.7.6 32 bit
>interactive interpreter on Windows.

He's sending us that stuff, but he may be writing it someplace else
first. And that someplace else may be spitting out combined
spaces and tabs. If he is pasting that into the interpreter,
that will cause tons of problems like he is seeing.

Laura

Mark Lawrence

unread,
Jul 12, 2015, 4:49:03 PM7/12/15
to pytho...@python.org
At 18:33 BST Simon stated "I typed in (and did not copy and paste) the
code...". I started my reply with "You can tell that to the marines :)".
0 new messages