Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/widnyana/py-dotenv
Load Configuration from .env file in current working directory
https://github.com/widnyana/py-dotenv
Last synced: 20 days ago
JSON representation
Load Configuration from .env file in current working directory
- Host: GitHub
- URL: https://github.com/widnyana/py-dotenv
- Owner: widnyana
- License: mit
- Created: 2015-08-19T07:17:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-27T14:18:17.000Z (almost 9 years ago)
- Last Synced: 2024-12-18T19:27:58.735Z (22 days ago)
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DotEnv
Load Configuration from .env file in current working directory
## Install
```
pip install git+git://github.com/widnyana/py-dotenv.git
```## Feature
this library provide ability to merge your config in `.env` file with current OS'
environment variable, with decision to override or not.## Usage
file `.env`
```
YOUR_KEYNAME=YOUR_VALUE
YOUR_KEYNAME2 = YOUR_VALUE2# ignored comment
```your code `main.py`
```
import os
from dotenv import Dotenvif __name__ == '__main__':
#: not overriding OS's env var
d = Dotenv()
#: or, override OS's env var
d = Dotenv(override=True)
#: then load the .env
d.load()
#: you can get it like this
print os.getenv("YOUR_KEYNAME") #: result -> YOUR_VALUE
#: or like this
print d.get("YOUR_KEYNAME", "DEFAULT_VAL")
```## License
[MIT License](http://widnyana.mit-license.org/)