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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 2Python 3

File details

Details for the file dfault-1.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dfault-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b7250aac5754a07c27d4830c846b8a673c749e7e6eb8ff1fd4403c63f877fb0
MD5 bc15de613cae72abd4685fced7dd79b2
BLAKE2b-256 2efb6822b849f6a4bcc0bf3be0fd6427b3054602063bac990f9f51e648fce957

See more details on using hashes here.

Supported by

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