Created
March 16, 2023 14:19
-
-
Save nerdinand/ad5b8ff3b41bf2f2d9f712ccd65f1ba6 to your computer and use it in GitHub Desktop.
Quick and dirty env.sh file reading and applying in Python (useful for example in a Jupyter Notebook)
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
import re | |
import os | |
for m in re.finditer(r'export (.*)=([^ \n]+)', open('../env.sh').read()): | |
os.environ[m[1]] = m[2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment