Skip to main content

python-lenv

Welcome to the lenv package page! This package allows you to quickly, efficiently and conveniently load environment variables into a class!

Features

  • Loading environment variables into class variables by variable name
  • Configuring the loading of changes using a variable of class meta

Installation

You can use your favorite package manager to install/update the lenv package. For example, pip, as in this example:

python3 -m pip install -U python-lenv

Usage/Examples

dotenv

First of all, let's define our .env file, which will be located in the startup directory of the main file.

I put the TOKEN and API_KEY there, in the future we will be able to get them through class variables

TOKEN=FOlCLYqcM.ZRgpwq.IrUyWYwjwSvFmCITCbmOBqvbqpZLWNrufvQKsrawplHMAwICSjBJvSlkJFaeENCrYkdOUeqSwmwQoMbTEJLLFLIGDLXaWF.HsNqciQnXitjhzXO
API_KEY=a3edffac-f4cc-4e68-9fd3-11e942fc7ea6

python

Finally, we come to our first example. We can use class variables to get environment variables directly through the class.

import lenv


class Config(lenv.EnvironmentLoader):
    # This configuration is not important, the default is used `lenv.DefaultMetadata` 
    # which has a file path like .env in it. But for example, let's leave it
    meta = lenv.ConfigurableMetadata(dotenv_path=".env")
    
    # These class variables will be used directly to access environment variables -O-
    TOKEN: str
    API_KEY: str


assert Config.TOKEN == 'FOlCLYqcM.ZRgpwq.IrUyWYwjwSvFmCITCbmOBqvbqpZLWNrufvQKsrawplHMAwICSjBJvSlkJFaeENCrYkdOUeqSwmwQoMbTEJLLFLIGDLXaWF.HsNqciQnXitjhzXO'
assert Config.API_KEY == 'a3edffac-f4cc-4e68-9fd3-11e942fc7ea6'

License

lenv is distributed under the terms of the MIT license.

Release files for python-lenv 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-lenv 0.5.0
File Size Uploaded
python_lenv-0.5.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-lenv 0.5.0
File Interpreter ABI Platform
python_lenv-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / python_lenv-0.5.0.tar.gz

Download URL python_lenv-0.5.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3de753d6e1654d54147508e701deef81e1480754006349bd975da3456050b809
BLAKE2b-256 checksum
How to use checksums
0b2927e040f62d55a9258548288916f79e35e067c70508d21367a06226b8a3bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / python_lenv-0.5.0-py3-none-any.whl

Download URL python_lenv-0.5.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad97638d47df0a5603511b7407d8dc8c0acf35b921cf18d04f4bdaeca66b9b6c
BLAKE2b-256 checksum
How to use checksums
bfca5a3b97140dc7d8c751727805380b6b14df050d6802bf840901d9b8d3616e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page