Programming-Idioms

History of Idiom 205 > diff from v11 to v12

Edit summary for version 12 :
New Python implementation by user [Pantelwolf]

Version 11

2019-09-29, 22:41:07

Version 12

2019-09-30, 12:00:44

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Extra Keywords
envvar os system
Extra Keywords
envvar os system
Imports
import os
Code
try:
    _foo = os.environ['FOO']
except KeyError:
    _foo = None
Doc URL
https://docs.python.org/3/library/os.html