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

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to