Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- ...
- # if the key doesn't exist than raise a 'KeyError'
- my_url = os.environ['my_variable_name']
- # using get will return 'None' if a key is not present rather than raise a 'KeyError'
- my_url = os.environ.get('KEY_THAT_MIGHT_EXIST')
- # os.getenv is equivalent, and can also give a default value instead of 'None'
- my_url = os.getenv('KEY_THAT_MIGHT_EXIST', default_value)
- ...
Add Comment
Please, Sign In to add comment