Skip to main content

appsettings

Sometimes you want to read a setting from the command line. Sometimes you want to read it from an environment variable. Sometimes you want to read it from a config file.

And in some very special times, you want to allow the value to be passed using some combination of the three.

The appsettings module provides an argparse subclass that allows pulling settings from the command line, environment variables, or a yaml config file.

If the same value is provided in several of those locations, then env var always beats config file, and command line always beats everything.

Usage is exactly the same as argparse, with the addition of some new kwargs on initializing the parser and adding arguments to it. Example:

from appsettings import SettingsParser

f = open('some_config_file.yaml')
parser  = SettingsParser(yaml_file=f)

parser.add_argument('--color', default='blue', env_var='FAVCOLOR')

args = parser.parse_args()

print args.color
# If you've set the FAVCOLOR environment variable you should now see its
# value printed to the console.  Otherwise you'd see 'blue'

Things to Know

Options Only

Only long form arguments like “–color” will provide env var and config file fallbacks. Positional arguments and short options like “-c” will behave just like they do in the argparse module.

APP_SETTINGS_YAML

If you don’t provide a yaml_file argument to the SettingsParser constructor, and the APP_SETTINGS_YAML environment variable is set, then that file will be read and parsed to provide settings. (Though they’ll still be overridable by environment variables and command line options.)

Metadata

Release files for appsettings 0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for appsettings 0.8
File Size Uploaded Provenance Actions
appsettings-0.8.tar.gz 3.8 kB Without provenance Details for appsettings-0.8.tar.gz

Release files / appsettings-0.8.tar.gz

Download URL appsettings-0.8.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8aa90699a67a90edf88b11b6f5d539506daee4395f7e6bbae62c5e6505b2ddd6
BLAKE2b-256 checksum
How to use checksums
c05bce768ca9fcbdb8bdb41b6c6032b0ebd12532b18670a10b5e4b5a01d67899
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for appsettings 0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page