2020-02-02 16:33:09 -05:00
|
|
|
"""
|
|
|
|
categories: Modules,os
|
|
|
|
description: ``environ`` attribute is not implemented
|
|
|
|
cause: Unknown
|
|
|
|
workaround: Use ``getenv``, ``putenv`` and ``unsetenv``
|
|
|
|
"""
|
|
|
|
import os
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2020-02-02 16:33:09 -05:00
|
|
|
try:
|
|
|
|
print(os.environ.get("NEW_VARIABLE"))
|
|
|
|
os.environ["NEW_VARIABLE"] = "VALUE"
|
|
|
|
print(os.environ["NEW_VARIABLE"])
|
|
|
|
except AttributeError:
|
|
|
|
print("should not get here")
|
|
|
|
print(os.getenv("NEW_VARIABLE"))
|
|
|
|
os.putenv("NEW_VARIABLE", "VALUE")
|
|
|
|
print(os.getenv("NEW_VARIABLE"))
|