Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

owattr overwrites attributes.

Project description

https://travis-ci.org/narusemotoki/owattr.svg?branch=master

owattr overwrites attributes.

Example

config.py:

import sys

import owattr


REDIS_URL = "redis://localhost:6379/0"
IS_DEV_ENV = True


owattr.from_dict(sys.modules[__name__], dict(os.environ))

The config module has REDIS_URL as attribute. You might want to change the value for your production environment. In this example, if you have defined REDIS_URL in environment variables, when you load config module, it is overwritten. If you don’t define REDIS_URL, you can use the original value. When owattr read the dict, it casts dict value to type of the original value. So in environment variable, everything is str type. In this example, if you have defined IS_DEV_ENV=False in environment variable, IS_DEV_ENV of config has False as bool type. Booleans are cast as follows:

  • 'false', 'False' and '' are cast to False
  • 'true' and 'True' are cast to True
  • anything else raises a 'ValueError'

If your object has __all__, owattr overwrites only variables which written in __all__.

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 owattr, version 0.10.0
Filename, size File type Python version Upload date Hashes
Filename, size owattr-0.10.0.tar.gz (2.5 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