Created
December 25, 2021 19:48
-
-
Save dmwyatt/d898f5fc203ee56e24e6dbe826b07d6e to your computer and use it in GitHub Desktop.
[read dot env] Read a .env file and set the env vars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with suppress(FileNotFoundError): | |
with open('.env') as f: | |
line = f.readline() | |
while line: | |
k, v = line.split('=', 1) | |
os.environ[k] = v.strip() | |
line = f.readline() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment