On Mon, 9 May 2005 16:23:08 -0700, Nalli Dinesh <[EMAIL PROTECTED]> wrote:
>This seems very easy, as every programming language provides this. But >I don;t know why I have this not working for me in Python scripts. >The problem: >I am trying to create and set environment variable LANG under windows >from Python file. I am using OS module's putenv or environ to do so. >But it is not really creating the environment variable or neither set >the same from the code. >This seems to be a easy fix, if anyone has a reason and fix for this >problem, please shoot it back to me. I am using python2.4 > > Paul is exactly right. You cannot change the environment of the shell from which you started, in any language, on any (popular) operating system. You can only affect your own environment, and those of any processes you start. This is usually enough: C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp>python Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['LANG'] Traceback (most recent call last): File "<stdin>", line 1, in ? File "c:\apps\python23\lib\os.py", line 417, in __getitem__ return self.data[key.upper()] KeyError: 'LANG' >>> os.environ['LANG']='language' >>> os.system('set L') LANG=language LIB=C:\VS.NET\VC7\ATLMFC\LIB;C:\VS.NET\VC7\LIB;C:\VS.NET\VC7\PlatformSDK\lib\pre release;C:\VS.NET\VC7\PlatformSDK\lib;C:\VS.NET\SDK\v1.1\lib; LOGNAME=timr LOGONSERVER=\\DOUG 0 >>> ^Z C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp> -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32