EnvEase
Persian Immortal Studios presents, A Python package to easily work with environment variables, inspired by the method used in Laravel framework to read the .env
file.
Installation
You can install envease
via pip:
pip install envease
Usage
if you only want to use a single .env
file where the python file is located then you can import the package like this:
from envease import env
then the usage is gonna be simple:
KEY="Hello, World"
print(env('KEY'))
else if you want to use other environment variable files than .env
you can use the package like this:
from envease import *
load_env_file('file_name')
print('KEY')
you can even dynamically call different environment variable files
from envease import *
env_files = {
"first": ".first.env",
"second": ".second.env",
"third": ".third.env",
}
load_multiple(env_files)
print(dynamic_env('first', 'KEY'))
Notice: you can as well handle default values if the returned value is null!
print('KEY', 'default value')
print(dynamic_env('first', 'KEY'), 'default value')
Contributing
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.