Skip to main content

No project description provided

Project description

speckenv because a speck is a synonym for a dot and because Speck is awesome.


Read the settings contained in ./.env into os.environ (or a different mapping; pass a dict-like object as mapping):

from speckenv import read_speckenv


Note that read_speckenv uses os.environ.setdefault to set new values, which means that if a particular key exists more than once in the file the first value is retained, not the last.

If the file is named differently or resides in a different path, pass the full path as first argument to read_speckenv.

Read individual values:

from speckenv import env

SETTING2 = env('SETTING2', default='bla')
SETTING3 = env('SETTING3 ', required=True)  # Fail hard if missing.
SETTING4 = env('SETTING4', coerce=bool)  # Coercion is also applied
                                         # to default values

# Different mapping: env('SOMETHING', mapping=...)

The following values are evaluated as Python literals:

BOOL=True  # And False, None etc.
SWEET_HOME=['localhost', '']

Additional whitespace around the equals sign is supported. Empty lines and lines starting with a # are ignored.

NOTE! You should treat everything except for the first argument to both env and read_speckenv as keyword-only. Since speckenv still supports Python 2 this isn’t enforced by the code right now.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for speckenv, version 1.3.1
Filename, size File type Python version Upload date Hashes
Filename, size speckenv-1.3.1-py2.py3-none-any.whl (4.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size speckenv-1.3.1.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page