[python-win32] LOCALE related stuff Re: Setting environment variables in windows from Python Programs-

Nalli Dinesh nalli.dinesh at gmail.com
Wed May 11 20:49:52 CEST 2005


Tim/Paul/Tony
Thanks for the suggestions and bringing clarity to the issue. After
understanding your suggestions, I want to go striaght to the actual
issue down below that made me to post environment issue.
The actual issue/Problem:
Its kind of funny tome right now, but letme shoot the problem so that
we can have a clear cut idea as in whats the bug in python, or may be
I don;t know I am missing on something.
I using locale.setlocale and u guys know when we use this setlocale.
Yes I am working on Localising my application-a pygtk application.
When one says 
import locale
locale.setlocale(locale.LC_ALL, ' ')

This sets the locale for all categories to the user's default setting
(typically specified in the LANG environment variable).
I use Python2.4
Before I start my application from the DOS command prompt, run this
command at the cmd prompt to set LANG environment. Which is "set
LANG=ja_JP"
And now if I run my python(that uses pygtk ) application it starts up
and locale.setlocale able to read this LANG variable and do the needed
setting for the locale.
But if I don;t define this variable at the command prompt before I
start the python application, but I define the environmen variable
LANG like os.environ['LANG'] = 'ja_JP'.
Then the setlocale doesn't set the locale as needed.

But here is the catch. If I am using python2.3 and do the above, the
setlocole set the locale as needede on the fly.

Whats going on ......I don;t know. If u guys know your suggestions are needed.



On 5/11/05, Tim Roberts <timr at probo.com> wrote:
> On Tue, 10 May 2005 15:41:30 -0700, Tony C <cappy2112 at gmail.com> wrote:
> 
> >Your example didn't try to define the variable, it only attempted to
> >look at it's current value
> >
> >try this
> >
> >
> >>>  C:\Tmp>set LANG
> >>>  Environment variable LANG not defined
> >>>
> >>>
> >
> >C:\tmp> set LANG="SOME_LANGUAGE"
> >set LANG
> >LANG="SOME_LANGUAGE"
> >
> >
> 
> I replied to Tony privately, because I did not see that he responded
> both to me and to the list.  I'll repeat the reply here.
> 
> This misses the point.  I DID define the variable inside the Python
> code, and the process that I launched from Python (using os.system) DID
> inherit that variable.  That's the best you can do: you can change the
> environment for the processes you start, but you cannot change the
> environment of the process that started you.
> 
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
> 
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


More information about the Python-win32 mailing list