putenv() and os.environ
Siggy Brentrup
bsb at winnegan.de
Mon Jan 17 15:16:20 EST 2000
Gerrit Holl <gerrit.holl at pobox.com> writes:
> Hello,
>
> >>> os.putenv('aaa', 'bbb')
> >>> os.environ.get('aaa')
>
> I can't get any environment variables not set with the os.environ
> dict. Shouldn't os.environ be rewritten in C then, so it can get
> the REAL environment variable?
That's documented behavior, cf. Lib Reference lib/os_procinfo.html:
putenv (varname, value)
Set the environment variable named varname to the string value. Such
changes to the environment affect subprocesses started with
os.system(), popen() or fork() and execv(). Availability: most
flavors of Unix, Windows.
When putenv() is supported, assignments to items in os.environ are
automatically translated into corresponding calls to putenv();
however, calls to putenv() don't update os.environ, so it is
actually preferable to assign to items of os.environ.
HIH
Siggy
More information about the Python-list
mailing list