On this page
os.putenv
Prev: os.pipe | Up: os | Next: os.read
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.putenv
Tags: #public #python3 #stdlib #os
Import
import os
from os import putenv
Signature & Overview
os.putenv(name, value, /)
Change or add an environment variable.
Usage
import os
# Prefer assigning os.environ["KEY"] = "val" instead of calling os.putenv() directly
os.environ["DEMO_PUTENV_TEST"] = "1"
assert os.environ.pop("DEMO_PUTENV_TEST") == "1"
Gotchas
- Does NOT update
os.environ: Callingos.putenv()directly leaves Python'sos.environdict out of sync—always setos.environ[k] = vinstead.
REPL Inspect
from os import putenv
help(putenv)
Linked from
Related notes
- tuts/python3/stdlib_module/os/pipe Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/read Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/os/abort Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/access Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chdir Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chmod Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chown shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/close shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count shared tags: #os, #stdlib