Flexible, easy Python project configuration
Project description
bobbie
| Version | |
| Status | |
| Documentation | |
| Tools | |
| Compatibility | |
| Stats | |
What is bobbie?
Named after Roberta Draper ("Bobbie") from "The Expanse," bobbie provides
a lightweight and easy-to-use way to store and access configuration settings for a Python project.
Why use bobbie?
There are numerous options for storing configuration settings in Python.
So, what makes bobbie different?
- Flexible: a
Settingsinstance is easily built from adict, Python module, or file (ini, json, toml, and yaml formats are supported). - Lightweight: an efficient codebase ensures a very small memory footprint.
- Intuitive: a
createclass method constructsSettings(from any data source). - Convenient: unlike
configparser, automatic data and type validation is performed whenSettingsis created.
The comparison table
below shows how bobbie compares to the other major options that store
configuration options for Python projects.
Getting started
Installation
To install bobbie, use pip:
pip install bobbie
Create a Settings instance
bobbie supports several ways to create a Settings instance. You can either:
- If the settings are in a file, call a class method specific to the file type (
from_yamlin the second example below); - Call a class method for the general type of source data (
from_dictorfrom_file); - Call the
createclass method and it will automatically figure out the appropriate constructor; or - If the settings data is in a
dict-like object, pass it as the first argument toSettings.
From a dict
import bobbie
configuration = {
'general': {
'verbose': False,
'seed': 43,
'parallelize': False},
'files': {
'source_format': 'csv',
'file_encoding': 'windows-1252',
'float_format': '%.4f',
'export_results': True}}
# You can pick a specific constructor method.
settings = bobbie.Settings.from_dict(configuration)
# Or, may use the general `create` method.
settings = bobbie.Settings.create(configuration)
# Or, just send a `dict` to `Settings` itself.
settings = bobbie.Settings(configuration)
From a file
import bobbie
# You may use the general `create` method.
settings = bobbie.Settings.create('settings_file.yaml')
# Or, the `from_file` method.
settings = bobbie.Settings.from_file('settings_file.yaml')
# Or, the `from_yaml` method. They all do the same thing.
settings = bobbie.Settings.from_yaml('settings_file.yaml')
# Or,
If the file is a Python module, it must contain a variable named settings in the module namespace
(unless you change the global setting for the variable name).
Contributing
Contributors are always welcome. Feel free to grab an issue to work on or make a suggested improvement. If you wish to contribute, please read the Contribution Guide and Code of Conduct.
Similar projects
There are a lot of great packages for storing project settings. The table below shows the features of the leading libraries.
Feature Comparison of Python Configuration Libraries
| Library | Typing | Secrets | dict | ini | json | py | toml | yaml |
|---|---|---|---|---|---|---|---|---|
bobbie |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
configParser |
✅ | |||||||
dynaconf |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ||
Parser-it |
✅ | ✅ | ✅ | ✅ | ✅ | |||
python-decouple |
✅ | ✅ | ✅ | |||||
pyconfig |
✅ | |||||||
pydantic-settings |
✅ | ✅ |
As you can see, bobbie lacks a method for storing passwords, encryption keys,
and other secrets. That is because it is focused on internal Python
projects and the goal of keeping its resource usage as low as possible. So, if
you need secrets stored in your project settings, there are several good options
linked above that you should explore.
Acknowledgments
I would like to thank the University of Kansas School of Law for tolerating and supporting this law professor's coding efforts, an endeavor which is well outside the typical scholarly activities in the discipline.
License
Use of this repository is authorized under the Apache Software License 2.0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bobbie-0.2.0.tar.gz.
File metadata
- Download URL: bobbie-0.2.0.tar.gz
- Upload date:
- Size: 117.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9735c3895246ca208728329e0bcff2af58d3657b03d7b9a2b9d26430c4934049
|
|
| MD5 |
46a92ced33305f8f6ddebc5d8ac7a370
|
|
| BLAKE2b-256 |
e97dd67589436d4d70d774b55d5ecf5010f88ec0df5347d2a4c2f5e2d8fd8f76
|
File details
Details for the file bobbie-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bobbie-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0129d2da4573704255ea7b3d8957410b9457918617cd6b12908b587fe4fd48e
|
|
| MD5 |
bfb81f8feb2417b5ed3880f15741a9eb
|
|
| BLAKE2b-256 |
0ec99aaf875c09218c36201774ed9948d8e30022ade6dd52469a2f737f70c766
|