On Aug 29, 9:50 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Aug 30, 11:21 am, [EMAIL PROTECTED] wrote: > > > > > >>> import os > > > >>> os.environ['PATH'] > > > 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;%C:\\WINNT%\ > > \system32;%C:\\WINNT%;%C:\\WINNT%\\System32\\Wbem' > > > >>> os.putenv('PATH', 'C:\\WINNT\\system32') > > > >>> os.environ['PATH'] > > > 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;%C:\\WINNT%\ > > \system32;%C:\\WINNT%;%C:\\WINNT%\\System32\\Wbem' > > > What am I doing wrong? How do I change the value of an environment > > variable? > > What you are missing is that os.environ is only populated from the > global process environment at process startup. > > If you update os.environ the changes will be pushed into the global > process environment as well. But if you use os.putenv() instead, > bypassing os.environ, the changes will not show in os.environ. > > To confirm that the global process environment is being updated, use > os.getenv(). > > Graham
Can you tell me what I am still missing please? >>> import os >>> >>> os.getenv('PATH') 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;%C:\\WINNT%\ \system32;%C:\\WINNT%;%C:\\WINNT%\\System32\\Wbem' >>> >>> os.putenv('PATH', 'C:\\WINNT\\system32') >>> >>> os.getenv('PATH') 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;%C:\\WINNT%\ \system32;%C:\\WINNT%;%C:\\WINNT%\\System32\\Wbem' >>> -- http://mail.python.org/mailman/listinfo/python-list