Skip to main content

A simple lightweight class that allows the user to fallback on default values

Project description

A simple lightweight class that allows the user to fallback on default values

Installation

pip3 install --user dfault

Usage

Basic Example

from dfault.objects import Dfault

expected_values = {
                    "search_engine": "duckduckgo",
                    "website": "http://www.duckduckgo.com"
                    }
d = Dfault(expected_values)
d.get("search_engine", "google") # returns "duckduckgo" as the value exists
d.get("favourite_team", "leafs") # returns "leafs" as there are no values for "favourite_team"

With Config

import configparser
from dfault.objects import Dfault

config = configparser.ConfigParser()

# .config:
# [USER]
# team=leafs
#

config.read(".config")
default_config = config["user"]
d = Dfault(default_config)
d.get("team", "raptors") # returns "leafs" as the value exiss in the config
d.get("username", "joeyism") # returns "joeyism" as there is no "username" value in the config file

Versions

  • 1.0.x

    • bug fixes

  • 1.0.0

    • First Publish

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dfault-1.0.5-py2.py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page