You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

getenv

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getenv

Environment variable definition with type

0.2.0
pipPyPI
Maintainers
1

getenv

Environment variable definition with type.

Install

pip install getenv

Usage

See example.py:

from getenv import Env


app_name = 'FOO'

# Set the prefix for env vars
Env.set_prefix(app_name)

# Define your envs
ENV_PROCESSES = Env('{prefix}_PROCESSES', type=int, default=1)
ENV_DEBUG = Env('{prefix}_DEBUG', type=bool, default=False)
ENV_OPERATOR = Env('{prefix}_OPERATOR', default=None)


def main():
    processes = ENV_PROCESSES.get()
    debug = ENV_DEBUG.get()
    operator = ENV_OPERATOR.get()

    print('Run {} processes, debug = {}, operator = {}'.format(processes, debug, operator))

Run example.py normally:

$ FOO_PROCESSES=3 python example.py
Run 3 processes, debug = False, operator = None

Then with envs:

$ FOO_PROCESSES=3 FOO_DEBUG=true FOO_OPERATOR=$(whoami) python example.py
Run 3 processes, debug = True, operator = reorx

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts