2020-02-02 21:33:09 +00:00
|
|
|
"""
|
|
|
|
categories: Modules,os
|
|
|
|
description: ``getenv`` only allows one argument
|
|
|
|
cause: Unknown
|
|
|
|
workaround: Test that the return value is ``None``
|
|
|
|
"""
|
|
|
|
import os
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2020-02-02 21:33:09 +00:00
|
|
|
try:
|
2020-03-23 02:26:08 +00:00
|
|
|
print(os.getenv("NEW_VARIABLE", "DEFAULT"))
|
2020-02-02 21:33:09 +00:00
|
|
|
except TypeError:
|
2020-03-23 02:26:08 +00:00
|
|
|
print("should not get here")
|
2020-02-02 21:33:09 +00:00
|
|
|
# this assumes NEW_VARIABLE is never an empty variable
|
2020-03-23 02:26:08 +00:00
|
|
|
print(os.getenv("NEW_VARIABLE") or "DEFAULT")
|