Version | |
Status | |
Documentation | |
Tools | |
Compatibility | |
Stats | |
bobbie
provides
a lightweight, easy-to-use, flexible, and extensible Settings
class for loading and
storing configuration settings for a Python project.
There are numerous options for storing project configuration settings in Python.
So, what makes bobbie
different?
- Flexible: a
Settings
instance is easily built from adict
, Python module, or file. - Lightweight: an efficient codebase ensures a very small memory footprint.
- Intuitive: a
create
class method constructsSettings
(from any data source). - Convenient: unlike
configparser
, automatic data and type validation is performed whenSettings
is created.
The comparison table
below shows how bobbie
compares to the other major options that store
configuration options for Python projects.
To install bobbie
, use pip
:
pip install bobbie
bobbie
supports several ways to create a Settings
instance. However, you can
opt to always use the create
class method for any data source.
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 may use the general `create` method.
settings = bobbie.Settings.create(configuration)
# Or, just send a `dict` to `Settings` itself.
settings = bobbie.Settings(configuration)
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')
If the file is a Python module, it must contain a variable named settings
(unless you change the global setting for the variable name).
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.
There are a lot of great packages for storing project settings. The table below shows the features of the leading libraries.
Library | Typing | Secrets | dict | env | 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 largely 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
listed above that you should explore.
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.
Use of this repository is authorized under the Apache Software License 2.0.