Browse Source
This adds the `default` argument of `os.getenv(key, default=None)`. Signed-off-by: David Lechner <david@pybricks.com>pull/8955/head
David Lechner
2 years ago
committed by
Damien George
2 changed files with 6 additions and 17 deletions
@ -1,14 +0,0 @@ |
|||||
""" |
|
||||
categories: Modules,os |
|
||||
description: ``getenv`` only allows one argument |
|
||||
cause: Unknown |
|
||||
workaround: Test that the return value is ``None`` |
|
||||
""" |
|
||||
import os |
|
||||
|
|
||||
try: |
|
||||
print(os.getenv("NEW_VARIABLE", "DEFAULT")) |
|
||||
except TypeError: |
|
||||
print("should not get here") |
|
||||
# this assumes NEW_VARIABLE is never an empty variable |
|
||||
print(os.getenv("NEW_VARIABLE") or "DEFAULT") |
|
Loading…
Reference in new issue