diff --git a/audeer/core/utils.py b/audeer/core/utils.py index 19006b6..5b95e2b 100644 --- a/audeer/core/utils.py +++ b/audeer/core/utils.py @@ -8,6 +8,7 @@ import inspect import multiprocessing import operator +import os import queue import subprocess import sys @@ -774,6 +775,22 @@ def sort_key(value): return sorted(versions, key=sort_key) +def set_or_delete_env_variable(name, value): + """Set or delete environment variable. + + Args: + name: name of environment variable + value: value of environment variable. + If ``None``, + the variable is deleted + + """ + if value is None: + del os.environ[name] + else: + os.environ[name] = value + + def to_list(x: typing.Any): """Convert to list.