https://github.com/messense/optionaldict
A dict-like object that ignore NoneType values for Python
https://github.com/messense/optionaldict
Last synced: about 1 year ago
JSON representation
A dict-like object that ignore NoneType values for Python
- Host: GitHub
- URL: https://github.com/messense/optionaldict
- Owner: messense
- License: mit
- Created: 2015-05-09T03:16:15.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-01-15T07:52:40.000Z (over 5 years ago)
- Last Synced: 2024-05-02T00:55:21.206Z (about 2 years ago)
- Language: Python
- Size: 8.79 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# optionaldict
[](https://travis-ci.org/messense/optionaldict)
[](https://ci.appveyor.com/project/messense/optionaldict/branch/master)
[](https://coveralls.io/r/messense/optionaldict)
``optionaldict`` is a dict-like object that ignore NoneType values for Python which is pickable and JSON serializable.
# Installation
You can install ``optionaldict`` simply using ``pip``:
```bash
pip install optionaldict
```
# Usage
``optionaldict``'s usage is very simple, you will import it by:
```python
from optionaldict import optionaldict
```
or if you prefer the CamelCasing style naming, you can import it by:
```python
from optionaldict import OptionalDict
```
> Tips: In fact, ``optionaldict`` is just an alias for ``OptionalDict``.
Then you can use it just like the built-in ``dict``:
```python
d1 = optionaldict(a=1, b=None)
d1['c'] = 2
d1.setdefault('d', None)
d2 = optionaldict()
d2['a'] = 1
d2['b'] = None
d3 = optionaldict({
'a': 1,
'b': None
})
```