Skip to main content
# Simple Config

A simple configuration file manager for python. Best suited for simple scripts that need
to take user defined configuration parameters.

Configuration is saved in JSON format to a file of your chosing.


## Why?

This is mostly intended to be used in quick and dirty scripts and simple CLI apps.
This does not intend to replace `configparser`. There are instances where I feel
that bootstrapping `configparser` is an overkill. This is where `simple_config` chips in.


## Installation

Install if using `pipenv` by running the command below.

```bash
pipenv install simple-config
```

Or, if you are not using `pipenv`, run the following:

```bash
pip install simple-config
```

## Usage

`simple-config` provides a `Config` class. It is intended to be instantiated
at the module level once and used the instance everywhere.

Put this in a file called `config.py`:

```python
from simple_config import Config

default_settings = {
"is_registered": True,
"token": "aK3NJe3PnXJr"
}
settings = Config("/path/to/config.json", defaults=default_settings)
```

Here, the first argument is the path to the configuration file.
The `defaults` keyword argument takes the default configuration
options for your app.
If the config file does not exist, it will be created and populated
with the default values.

Now, import the instance of `Config` i.e. `settings` wherever necessary and use:

```python
from config import settings

print(settings.token)
```

### Mutating the config

Sometimes there might be a need to update the config, e.g. to save state of
the app. The `Config` class provides `update` instance method.

```python
settings.update(token="Ju901jK1Rb")
```

The update method will update the parameters and write it to the config
file as well.


## Multiple configs

There can exist more than one `Config` instance in an application. For example,
the application auto-generated state can be saved in one file and user's config
can be saved in another instance.


## Run the tests

Go to the root of this project and run:

```python
python -m unittest discover
```


## Similar projects

* [yapconf](https://github.com/loganasherjones/yapconf)


Metadata

Release files for simple-config 1.0.1

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

Source distribution (sdist)

Source distribution for simple-config 1.0.1
File Size Uploaded Provenance
simple-config-1.0.1.linux-x86_64.tar.gz 2.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for simple-config 1.0.1
File Interpreter ABI Platform
simple_config-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 7.3 kB

Release files / simple-config-1.0.1.linux-x86_64.tar.gz

Download URL simple-config-1.0.1.linux-x86_64.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b9588085ebb82a9b6ec21d60917c908acda68da6473eb2ac6178f9f3b59ebf16
BLAKE2b-256 checksum
How to use checksums
5505a0f51d7c29920f91330ce87707bf0fa6f769e2838c1c434a311cbc2d56d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / simple_config-1.0.1-py2.py3-none-any.whl

Download URL simple_config-1.0.1-py2.py3-none-any.whl
Size 4.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
06e62440ae51a49073935d84cf21d2fb3c812d3bec6dce392e0b36cd4e1f487c
BLAKE2b-256 checksum
How to use checksums
639d250327515576377d533be41e566f3b27fdbf9d1f88545def24fd2e44fc44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for simple-config 1.0.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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