Created
May 22, 2025 18:40
-
-
Save vadimkantorov/9bde48a0af550b6a0b91720587895948 to your computer and use it in GitHub Desktop.
toml can abused to read some basic key-value pairs as well
This file contains hidden or 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
def load_dotenv(dotenv_path = '.env'): | |
# https://snarky.ca/use-toml-for-env-files/ | |
# https://github.com/theskumar/python-dotenv | |
''' | |
# such simple key-value files are toml subset and can be read via tomllib without external packages or hacks | |
a="b" | |
c="d" | |
''' | |
import os, tomllib | |
os.environ.update(tomllib.load(open(dotenv_path, 'rb'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment