On this page
  1. os.putenv
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from os import putenv
help(putenv)

Linked from

Related notes