Storing application variables in a 'hidden' file called .env?
Need to load these variables for dev/testing but didn't start jupyter notebook with them already exported?
Just drop the following into a Python 3 cell.
| ## bootstrap environment variables from file | |
| from configparser import RawConfigParser | |
| from itertools import chain | |
| from os import environ | |
| config = RawConfigParser() | |
| with open('.env','r') as f: | |
| config.read_file(chain(("[DEFAULT]",), f)) | |
| for k,v in config.items('DEFAULT'): | |
| environ[k.upper().replace('EXPORT ','')] = v |