Content-Length: 266754 | pFad | http://github.com/hailiang-wang/python-env3

74 GitHub - hailiang-wang/python-env3: A .env file reader for Python.
Skip to content

hailiang-wang/python-env3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python env3

https://github.com/hailiang-wang/python-env3

.env file reader.

pip install -U env3
  1. first, try to read env from parameter
  2. second, try to read env from cwd dir
  3. third, try to read env from ~/.env
  4. if above envfile not present, just return the current ENV as ENVIRON = os.environ.copy()
import env3

ENV = env3.load_env() # env3.load_env(ENV_FILE_PATH), ENV_FILE_PATH is optional
print(ENV)
print(ENV.get("DEEKSEEK_MODEL"))
print(ENV.get("DEEKSEEK_MODEL2", "foo"))
env3.print_env(ENV)

Use env3.read_env() if don't want to impact the os.environ, but get another ENV instance only.

Best practice

import os, env3
env3.load_env(os.path.join(os.getcwd(), ".env"))

os.environ.get("SOME_KEY", "default value")

License

LICENSE

About

A .env file reader for Python.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/hailiang-wang/python-env3

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy