Skip to content

Instantly share code, notes, and snippets.

@vadimkantorov
Created May 22, 2025 18:40
Show Gist options
  • Save vadimkantorov/9bde48a0af550b6a0b91720587895948 to your computer and use it in GitHub Desktop.
Save vadimkantorov/9bde48a0af550b6a0b91720587895948 to your computer and use it in GitHub Desktop.
toml can abused to read some basic key-value pairs as well
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