Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

433 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Python .ENV

This project exists for one simple reason: to provide a simple, zero-dependency .env file loader for Python projects.

This is a perfect project for small utility scripts, where you might need to load environment variables but don't want to install any extra deps.

Usage

  1. Copy the contents of src/main.py, including the full header, to any file in your project.
  2. Somewhere in your script, run the load_dotenv(path) function. The parameters and requirements differ slightly from python-dotenv:
    • path: Path to the .env file. type: str | os.PathLike[str]
      • This is required. I recommend using a pathlib.Path, but strings work as well. (Technically speaking, any type/class that defines a __fspath__ method is compatible)
    • override_existing: Whether to override existing environment variables. type: bool (default: False)
    • encoding: Encoding to be used to read the file. type: str | None (default: "utf-8")
  3. Now, you can access environment vars as usual with os.getenv().

Supported versions

This project has been tested on and should work on Python versions 3.7 and above.

Licensing

This project is licensed under the MIT License. You are free to use this project how you please, as long as you include the original license text along with the code.

About

A simple .env file loader that can be copied straight into a Python script

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages