.env file parser with interpolation and multi-file support
Project description
philiprehberger-env-file
.env file parser with interpolation and multi-file support.
Installation
pip install philiprehberger-env-file
Usage
Load into Environment
from philiprehberger_env_file import load_env
# Load .env (default)
load_env()
# Load multiple files (later files override earlier)
load_env(".env", ".env.local")
# Don't override existing env vars
load_env(override=False)
Parse Without Modifying Environment
from philiprehberger_env_file import parse_env_file
config = parse_env_file(".env")
print(config["DATABASE_URL"])
Supported Syntax
# Comments
KEY=value
export KEY=value
# Quoted values
SINGLE='no interpolation here'
DOUBLE="supports\nnewlines"
# Variable interpolation
BASE_URL=https://api.example.com
API_URL=${BASE_URL}/v1
# Empty values
EMPTY_VAR=
# Inline comments (unquoted values only)
HOST=localhost # this is a comment
API
load_env(*paths, override=True)— Load .env files intoos.environ, returns dict of loaded varsparse_env_file(path)— Parse a .env file, returns dict without modifying environment
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_env_file-0.1.3.tar.gz.
File metadata
- Download URL: philiprehberger_env_file-0.1.3.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23d4ca8f2595a0cae7893d9db9606b5c9cdc2449bf5aac555c92cae479a57e1d
|
|
| MD5 |
49c8af90b3fc1b622576b7d1695c8d16
|
|
| BLAKE2b-256 |
df599749989a6c5baae17ced8b3a532cb9e40fafa68b6219c407df8875a07c21
|
File details
Details for the file philiprehberger_env_file-0.1.3-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_env_file-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
533a695e74be70672d43a3856211b5f14a269d4adcda6b09e90f61074e5f456c
|
|
| MD5 |
86acfdd75f9ef7283245c6074efbcf3a
|
|
| BLAKE2b-256 |
0309259c1adad3ddcb1854307d7425b387e7a7d4690247b9e1e4e2d6a07a9cfe
|